-->2+2 ans = 4. -->2+2; -->// Scilab uses the C++ style slash slash comments -->// Note that the ; is the silent command -->// Often one does not want to see all of a 100x100 matrix -->// This file started with diary('scilab-diary.txt') -->// colon -->1:10 ans = ! 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. ! -->10:-2:0 ans = ! 10. 8. 6. 4. 2. 0. ! -->// dot operators do term by term for example 1^2 2^2 ... 10^2 -->(1:10).^2 ans = ! 1. 4. 9. 16. 25. 36. 49. 64. 81. 100. ! -->// normal operators are matrix operators -->a = [.9, .5; .1, .5] a = ! 0.9 0.5 ! ! 0.1 0.5 ! -->a^2 ans = ! 0.86 0.7 ! ! 0.14 0.3 ! -->a^10 ans = ! 0.8333508 0.8332460 ! ! 0.1666492 0.1667540 ! -->sum(a,c) !--error 4 undefined variable : c -->sum(a,'c') ans = ! 1.4 ! ! 0.6 ! -->sum(a,'r') ans = ! 1. 1. ! -->// example of error, and confusing commands -->spec(a) ans = ! 1. ! ! 0.4 ! -->[x,d]=spec(a) d = ! 1. 0 ! ! 0 0.4 ! x = ! 0.9805807 - 0.7071068 ! ! 0.1961161 0.7071068 ! -->a(1,:) ans = ! 0.9 0.5 ! -->a(:,1) ans = ! 0.9 ! ! 0.1 ! -->norm(a(:,1)) ans = 0.9055385 -->norm(x(:,1)) ans = 1. -->norm(x(:,2)) ans = 1. -->// norm is sqrt of sum of squares -->v=[1,1,1] v = ! 1. 1. 1. ! -->v' ans = ! 1. ! ! 1. ! ! 1. ! -->sqrt(v.^2) ans = ! 1. 1. 1. ! -->sqrt(v * v') ans = 1.7320508 -->v*v' ans = 3. -->v'*v ans = ! 1. 1. 1. ! ! 1. 1. 1. ! ! 1. 1. 1. ! -->// a(i,j) = i*j^2 5x5 -->(1:5).^2'*1:5 !--error 204 Argument 1, wrong type argument: expecting a scalar -->(1:5).^2'*(1:5) !--error 10 inconsistent multiplication -->((1:5).^2)'*(1:5) ans = ! 1. 2. 3. 4. 5. ! ! 4. 8. 12. 16. 20. ! ! 9. 18. 27. 36. 45. ! ! 16. 32. 48. 64. 80. ! ! 25. 50. 75. 100. 125. ! -->b=((1:5).^2)'*(1:5) b = ! 1. 2. 3. 4. 5. ! ! 4. 8. 12. 16. 20. ! ! 9. 18. 27. 36. 45. ! ! 16. 32. 48. 64. 80. ! ! 25. 50. 75. 100. 125. ! -->spec(b) ans = ! 0 ! ! 225. ! ! - 4.477E-15 ! ! 6.769E-16 + 6.796E-16i ! ! 6.769E-16 - 6.796E-16i ! -->[x,d]=spec(b) d = column 1 to 4 ! 0 0 0 0 ! ! 0 225. 0 0 ! ! 0 0 - 4.477E-15 0 ! ! 0 0 0 6.769E-16 + 6.796E-16i ! ! 0 0 0 0 ! column 5 ! 0 ! ! 0 ! ! 0 ! ! 0 ! ! 6.769E-16 - 6.796E-16i ! x = column 1 to 4 ! 0.9903945 - 0.0319601 0.4682126 - 0.7226398 ! ! - 0.0176856 - 0.1278406 - 0.4138566 - 0.0027952 + 0.0526997i ! ! - 0.0397926 - 0.2876412 - 0.1517292 0.1804905 - 0.0445672i ! ! - 0.0707425 - 0.5113622 - 0.5102111 - 0.4092317 - 0.2893300i ! ! - 0.1105351 - 0.7990035 0.5711065 0.3647371 + 0.2371245i ! column 5 ! - 0.7226398 ! ! - 0.0027952 - 0.0526997i ! ! 0.1804905 + 0.0445672i ! ! - 0.4092317 + 0.2893300i ! ! 0.3647371 - 0.2371245i ! -->rref(b) ans = ! 1. 2. 3. 4. 5. ! ! 0. 0. 0. 0. 0. ! ! 0. 0. 0. 0. 0. ! ! 0. 0. 0. 0. 0. ! ! 0. 0. 0. 0. 0. ! -->// How wrong can it be??? b has 0 as eigenvector 4 times. -->d=[1, 1, 0,0; 0,1,1,0; 0,0,1,1; 0,0,0,1] d = ! 1. 1. 0. 0. ! ! 0. 1. 1. 0. ! ! 0. 0. 1. 1. ! ! 0. 0. 0. 1. ! -->[x,d2]=spec(d) d2 = ! 1. 0 0 0 ! ! 0 1. 0 0 ! ! 0 0 1. 0 ! ! 0 0 0 1. ! x = ! 1. - 1. 1. - 1. ! ! 0 2.220E-16 - 2.220E-16 2.220E-16 ! ! 0 0 4.930E-32 - 4.930E-32 ! ! 0 0 0 1.095E-47 ! -->rref(d) ans = ! 1. 0. 0. 0. ! ! 0. 1. 0. 0. ! ! 0. 0. 1. 0. ! ! 0. 0. 0. 1. ! -->eye(4) ans = 1. -->eye(4,4) ans = ! 1. 0. 0. 0. ! ! 0. 1. 0. 0. ! ! 0. 0. 1. 0. ! ! 0. 0. 0. 1. ! -->rref(d-eye(4,4)) ans = ! 0. 1. 0. 0. ! ! 0. 0. 1. 0. ! ! 0. 0. 0. 1. ! ! 0. 0. 0. 0. ! -->// d has only one independent eigenvector for eigenvalue 1 -->ni=d-eye(4,4) ni = ! 0. 1. 0. 0. ! ! 0. 0. 1. 0. ! ! 0. 0. 0. 1. ! ! 0. 0. 0. 0. ! -->ni^2 ans = ! 0. 0. 1. 0. ! ! 0. 0. 0. 1. ! ! 0. 0. 0. 0. ! ! 0. 0. 0. 0. ! -->ni^3 ans = ! 0. 0. 0. 1. ! ! 0. 0. 0. 0. ! ! 0. 0. 0. 0. ! ! 0. 0. 0. 0. ! -->ni^4 ans = ! 0. 0. 0. 0. ! ! 0. 0. 0. 0. ! ! 0. 0. 0. 0. ! ! 0. 0. 0. 0. ! -->1+%i ans = 1. + i -->norm(1+%1) !--error 4 undefined variable : %1 -->norm(1+%i) ans = 1.4142136 -->(1+%i)' ans = 1. - i -->zeros(3,4) ans = ! 0. 0. 0. 0. ! ! 0. 0. 0. 0. ! ! 0. 0. 0. 0. ! -->ones(3,4) ans = ! 1. 1. 1. 1. ! ! 1. 1. 1. 1. ! ! 1. 1. 1. 1. ! -->rand(3,4) ans = ! 0.2113249 0.3303271 0.8497452 0.0683740 ! ! 0.7560439 0.6653811 0.6857310 0.5608486 ! ! 0.0002211 0.6283918 0.8782165 0.6623569 ! -->// end the text with diary(0) -->diary(0)