summaryrefslogtreecommitdiff
path: root/tests/unit_tests/test000_TrigonIdentity/scilabcode
diff options
context:
space:
mode:
authornutricato2009-07-07 11:06:39 +0000
committernutricato2009-07-07 11:06:39 +0000
commita484e92e9ca595b25036c11d6b259ba98ee1765c (patch)
tree09943abe86ddff54bc11b4f096480605577d66ed /tests/unit_tests/test000_TrigonIdentity/scilabcode
parent6dfd653d3622c17a8265a0f09f8e50037e9bec2d (diff)
downloadscilab2c-a484e92e9ca595b25036c11d6b259ba98ee1765c.tar.gz
scilab2c-a484e92e9ca595b25036c11d6b259ba98ee1765c.tar.bz2
scilab2c-a484e92e9ca595b25036c11d6b259ba98ee1765c.zip
Diffstat (limited to 'tests/unit_tests/test000_TrigonIdentity/scilabcode')
-rw-r--r--tests/unit_tests/test000_TrigonIdentity/scilabcode/mainfunction.sci74
1 files changed, 24 insertions, 50 deletions
diff --git a/tests/unit_tests/test000_TrigonIdentity/scilabcode/mainfunction.sci b/tests/unit_tests/test000_TrigonIdentity/scilabcode/mainfunction.sci
index a29a1c9e..0b5e7249 100644
--- a/tests/unit_tests/test000_TrigonIdentity/scilabcode/mainfunction.sci
+++ b/tests/unit_tests/test000_TrigonIdentity/scilabcode/mainfunction.sci
@@ -2,54 +2,28 @@
function mainfunction()
-// 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!
-
-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);
-
-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');
-disp(a)
-disp('aeq');
-disp(aeq)
-
-disp('b');
-disp(b)
-disp('beq');
-disp(beq)
-
-// plot(Volume,Pressure);
-// plot(Volume,(C ./(Volume.^gamma)),'r')
+// ------------------------------
+// --- Simple Scalar Addition ---
+// ------------------------------
+a = 1;
+b = 2;
+c = 0;
+c = a + b;
+disp(c);
+
+// ------------------------------
+// --- Trigonometric Identity ---
+// ------------------------------
+x = (1:3)' * (4:9);
+y = (sin(x).^2) + (cos(x).^2);
+disp(x);
+disp(y-ones(3,6));
+
+// -------------------------------
+// --- 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);
endfunction