diff options
author | nutricato | 2008-06-09 10:01:45 +0000 |
---|---|---|
committer | nutricato | 2008-06-09 10:01:45 +0000 |
commit | 3d45fab989805822c5c8dd697aef90e0564ade5c (patch) | |
tree | 1fc07136d4a8906a3f1008d1c767a8f3b9744956 /src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode | |
parent | 570999d72a986dce58e5178586c579975f424910 (diff) | |
download | scilab2c-3d45fab989805822c5c8dd697aef90e0564ade5c.tar.gz scilab2c-3d45fab989805822c5c8dd697aef90e0564ade5c.tar.bz2 scilab2c-3d45fab989805822c5c8dd697aef90e0564ade5c.zip |
Diffstat (limited to 'src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode')
-rw-r--r-- | src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci b/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci index bfb5fc3f..75829d99 100644 --- a/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci +++ b/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci @@ -1,29 +1,46 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE +//SCI2C: DEFAULT_PRECISION= DOUBLE
-function mainfunction() +function mainfunction()
-// ------------------------------ -// --- Simple Scalar Addition --- -// ------------------------------ -a = 1; -b = 2; -c = 0; -c = a + b; -disp(c); +// Knowing that +// (1) P * (V^gamma) = C +// Where +// P = Pressure +// V = Volume +// gamma,C = constants depending on the particular gas used. +// (2) log10(P) = log10(C) - gamma*log10(V) +// (3) x = log10(V) +// (4) y = log10(P) +// than (2) becomes: +// y = a + b*x; +// Where +// a = log10(C) +// b = -gamma +// Then thanks to this transformation it is possible to perform +// a linear regression to estimate gamma and C! -// ------------------------------ -// --- Trigonometric Identity --- -// ------------------------------ -x = (1:3)' * (4:9); -y = (sin(x).^2) + (cos(x).^2); -disp(x); -disp(y-ones(3,6)); +Volume = [54.3 61.8 72.4 88.7 118.6 194.0]; +Pressure = [61.2 49.5 37.6 28.4 19.2 10.1]; +x = log10(Volume); +y = log10(Pressure); -// ------------------------------- -// --- Computation of Distance --- -// ------------------------------- -// generate a vector w -w = cos(sin(cos(x*3)*2).* x+ones(3,6).*cos(x-sin(y*2))); -distxw = sqrt(x.^2 + w.^2); -disp(distxw); +a = (sum(y)*sum(x.^2)-sum(x)*sum(x.*y))./(length(x)*sum(x.^2)-sum(x).*sum(x)); +b = (length(x)*sum(x.*y)-sum(x)*sum(y))./(length(x)*sum(x.^2)-sum(x).*sum(x)); + +// Other way to compute a and b +beq = sum((x-mean(x)).*(y-mean(y)))./sum((x-mean(x)).^2);
+aeq = mean(y)-mean(x)*beq;
+ +C = 10 .^a; +gamma = -b; +disp('C') +disp(C) +disp('gamma'); +disp(gamma); +disp('a-aeq'); +disp(a-aeq) +disp('b-beq') +disp(b-beq) +// plot(Volume,Pressure); +// plot(Volume,(C ./(Volume.^gamma)),'r') endfunction |