home *** CD-ROM | disk | FTP | other *** search
-
-
- function min_function(plot : Boolean; var point : TsingleArray) : mysingle;
-
- var F : mysingle;
- data : integer;
- A1,A2,A3,A4,A5,x1,x2,x3,x4,x5 : mysingle;
- i : integer;
- s2 : mysingle;
- x,y : integer;
- scale : Mysingle;
- inc : mysingle; { decay rate of weighting exponential }
-
- {$I equ.inc}{function Fn(i)}
-
- begin
-
- A1 := point[1];
- A2 := point[3];
- A3 := point[5];
- A4 := point[7];
- A5 := point[9];
- x1 := point[2];
- x2 := point[4];
- x3 := point[6];
- x4 := point[8];
- x5 := point[10];
-
- s2 := 0;
- scale := 32768/(FullScale - ZeroScale);
- inc := weighting/(endFit1-startFit1);
- IF CHECK THEN BEGIN
- FOR I := 1 TO NUMVAR DO WRITE('PNT[',I,']:',POINT[I]:8,' ');
- END
- ELSE
-
- i := startFit1;
-
- if weighting<>0 then begin
- repeat
- F := (Fn(i-StartFit1) - zero_scale)*scale;
- s2 := s2 + sqr(F-dataPTR^[i])*exp((i-StartFit1)*inc);
- i := i + round(skip_points*exp(-(i-StartFit1)*inc));
- until i>EndFit1;
- end;
-
- if weighting=0 then begin
- repeat
- F := (Fn(i - StartFit1) - zero_scale)*scale;
- s2 := s2 + sqr(F-dataPTR^[i]);
- i := i + skip_points;
- until i>EndFit1;
- end;
-
- if ((s2<=minstore) or plot) then begin
- for i := StartFit1 to EndFit1 do begin
- F := (Fn(i - StartFit1) - zero_scale)*scale;
- if F > 32767 then F := 32767;
- if F < -32766 then F := -32766;
- solutionPTR^[i] := round(F);
- end;
- { IF NOT CHECK THEN}
- { autoscale_plot(0,14,Xoffset,Yoffset,Xscale,Yscale,minData,}
- 'invert',StartFit1,EndFit1,skip_points,solutionPTR);}
- { IF NOT CHECK THEN
- autoscale_plot(0,14,Xoffset,Yoffset,Xscale,Yscale,minData,
- 'invert',StartFit1,EndFit1,skip_points,solutionPTR);}
- end;
- min_function := s2;
- IF CHECK THEN WRITE('S2:',S2:6,#13,#10);
-
- end;{ of function min_function----------------------------------------------}
- {---------------------------------------------------------------------------}
- {---------------------------------------------------------------------------}
-
-
- procedure choose_equ;
-
- var template, equs : text;
- ch : char;
-
- begin
- set_screen_size;
- window(1,1,width,height);
- clrscr;
- assign(template,'equ.scr');
- assign(equs,'equ.inc');
- reset(template);
- reset(equs);
- while (not EOF(template)) do begin
- read(template,ch);
- write(ch);
- end;
- window(2,1,width,height);
- gotoXY(1,1);
- while (not EOF(equs)) do begin
- read(equs,ch);
- write(ch);
- end;
- close(template);
- close(equs);
- gotoXY(2,23);
- window(2,23,78,23);
- write('Choose one of the above equations by number:');
- window(whereX+2,23,whereX+4,23);
- textbackground(15);
- textcolor(0);
- writeln;
- repeat
- read(eq_num);
- until ((IOresult=0) and (inputcheck(eq_num,1,7)));
- textcolor(15);
- textbackground(0);
- end; { of procedure choose_equ.---------------------------------------------}
- {---------------------------------------------------------------------------}
- {---------------------------------------------------------------------------}