diff options
Diffstat (limited to 'matheunit.pas')
-rw-r--r-- | matheunit.pas | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/matheunit.pas b/matheunit.pas index e9f2a16..e8a1e1e 100644 --- a/matheunit.pas +++ b/matheunit.pas @@ -53,6 +53,7 @@ function formelnAuswerten(s: string; kvs: tKnownValues; cbgv: tCallBackGetValue) function knownValue(nam: string; val: extended): tKnownValue; function berechneEinheitsZelle(invarianz,modulus: tInt64Point): tInt64Point; function ggT(a,b: int64): int64; +function ermittleAnstieg(dat: string; xSpalte,ySpalte: int64): extended; implementation @@ -332,7 +333,7 @@ begin result:=result/10 + ord(s[i])-ord('0'); result:=result/10 + ord(s[1])-ord('0'); end - else result:=strtofloat(s); + else result:=strToFloat(s); result:=result*power(10,e); if neg then result:=-result; @@ -539,7 +540,7 @@ begin cbv:=false; for i:=1 to length(s) do cbv:=cbv or not (s[i] in ['-','0'..'9','.',',','e','E']); - if not cbv then result:=strtofloat(s) + if not cbv then result:=strToFloat(s) else if not (assigned(kvs) and kvs.extract(s,result)) then begin if st then result:=1 else if assigned(cbgv) then result:=cbgv(s) @@ -852,5 +853,46 @@ begin // a <= b result:=b; end; +function ermittleAnstieg(dat: string; xSpalte,ySpalte: int64): extended; +var + f: textFile; + s: string; + xSum,xQdrSum,ySum,xySum: extended; + wert: tExtPoint; + i,anz: int64; +begin + if xSpalte=ySpalte then begin + result:=1; + exit; + end; + anz:=0; + xSum:=0; + ySum:=0; + xySum:=0; + xQdrSum:=0; + assignFile(f,dat); + reset(f); + while not eof(f) do begin + readln(f,s); + for i:=0 to min(xSpalte,ySpalte)-1 do + erstesArgument(s); + wert[char(ord('x')+byte(ySpalte<xSpalte))]:= + strToFloat(erstesArgument(s)); + for i:=min(xSpalte,ySpalte)+1 to max(xSpalte,ySpalte)-1 do + erstesArgument(s); + wert[char(ord('x')+byte(xSpalte<ySpalte))]:= + strToFloat(erstesArgument(s)); + inc(anz); + xSum:=xSum+wert['x']; + ySum:=ySum+wert['y']; + xySum:=xySum+wert['x']*wert['y']; + xQdrSum:=xQdrSum+sqr(wert['x']); + end; + closeFile(f); + if anz=0 then + fehler('Keine Werte in Anstiegs-Datei'''+dat+'''!'); + result:=(anz*xySum-xSum*ySum)/(anz*xQdrSum-sqr(xSum)) +end; + end. |