summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-11-08 16:00:54 +0100
committerErich Eckner <git@eckner.net>2017-11-08 16:02:50 +0100
commit6b624c81a152b8a33ed19eba2350a92f2f8e4a40 (patch)
tree78394c82fa391cf0575342621df0d161c3f46a3e
parenta9f2070dcf401d9362c918c913f147ed9bf32f47 (diff)
downloadunits-6b624c81a152b8a33ed19eba2350a92f2f8e4a40.tar.xz
matheunit.pas: ermittleAnstieg neu
-rw-r--r--lowlevelunit.pas2
-rw-r--r--matheunit.pas46
2 files changed, 45 insertions, 3 deletions
diff --git a/lowlevelunit.pas b/lowlevelunit.pas
index fd83c11..1497d2c 100644
--- a/lowlevelunit.pas
+++ b/lowlevelunit.pas
@@ -512,7 +512,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;
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.