home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
SCIENCE
/
DELPX02.ZIP
/
OLDFNUNI.INC
< prev
next >
Wrap
Text File
|
1991-06-17
|
3KB
|
116 lines
function min_function(plot : Boolean; var point : var_Array) : 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 Oldequ.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/(Full_Scale - Zero_Scale);
inc := weighting/(startData-endData);
IF CHECK THEN BEGIN
FOR I := 1 TO NUM_VARIABLES DO WRITE('PNT[',I,']:',POINT[I]:8,' ');
END
ELSE
i := startdata;
if weighting<>0 then begin
repeat
F := (Fn(i-startdata) - zero_scale)*scale;
s2 := s2 + sqr(F-dataPTR^[i])*exp((i-startdata)*inc);
i := i + round(skip_points*exp(-(i-startdata)*inc));
until i>enddata;
end;
if weighting=0 then begin
repeat
F := (Fn(i - startdata) - zero_scale)*scale;
s2 := s2 + sqr(F-dataPTR^[i]);
i := i + skip_points;
until i>enddata;
end;
if ((s2<=minstore) or plot) then begin
for i := startdata to enddata do begin
F := (Fn(i - startdata) - 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',startdata,enddata,skip_points,solutionPTR);}
{ IF NOT CHECK THEN
autoscale_plot(0,14,Xoffset,Yoffset,Xscale,Yscale,minData,
'invert',startdata,enddata,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.---------------------------------------------}
{---------------------------------------------------------------------------}
{---------------------------------------------------------------------------}