rem Data Peak Finder [loop] cls print print "Data Peak Finder Using Least Squares" print " equally spaced points" print REM enter data dim y(100) dim z(100) rem data entry input "Number of points to input? ";n [dleap] input "Use keyboard (k) or read from data (d)? ";c$ if c$="k" then for i=1 to n print "y(";i;")= "; input " ";y1 y(i)=y1 next i end if if c$="d" then for i=1 to n read y1 y(i)=y1 next i end if if c$<>"d" and c$<>"k" then [dleap] rem mode of operation print "Chose mode:" print " 1. Absolute max and min. " print " 2. Calculated max and min." print " 3. Quit." print [again] input "(1,2,3) ";q if q=1 then gosub [absolute] if q=2 then gosub [relative] if q=3 then end gosub [again] print rem absolute min and max [absolute] a=y(3) b=y(3) j=3 k=3 for r=3 to n-2 if a>y(r) then goto [aleap] else a=y(r) j=r end if goto [bleap] [aleap] if y(r)>b then goto [bleap] else b=y(r) k=r end if [bleap] next r gosub [fit] gosub [prin] return rem find deriative [relative] for k=3 to n-2 z(k)=y(k+1)-y(k-1)+2*(y(k+2)-y(k-2)) z(k)=z(k)/10 next k z(1)=z(3) z(2)=z(3) z(n)=z(n-2) z(n-1)=z(n) rem find zeros for k=4 to n-2 t=z(k)*z(k-1) if t>=0 then [rleap] j=k gosub [fit] u=x j=k-1 gosub [fit] if abs(x)