04-Nov-2013 1> % programmazione: script, function 1> % script moltiplicazione.m 1> edit moltiplicazione.m 2> moltiplicazione p = 12 3> a a = 3 4> b b = 4 5> clear all 6> a error: 'a' undefined near line 6 column 1 6> % funzione che calcola l'angolo in gradi e in radianti 6> % tra due vettori di R^n 6> edit angolo.m 7> help angolo 'angolo' is a function from the file C:\cygwin\home\achilles\angolo.m [gradi, rad] = angolo(v, w) calcola l'angolo in gradi e in radianti tra due vettori v e w di R^n Additional help for built-in functions and operators is available in the online version of the manual. Use the command 'doc ' to search the manual index. Help and information about Octave is also available on the WWW at http://www.octave.org and via the help@octave.org mailing list. 8> a = [1 1 1] a = 1 1 1 9> b = [1 1 0] b = 1 1 0 10> angolo(a,b) ans = 35.264 11> [g, r] = angolo(a,b) g = 35.264 r = 0.61548 12> c error: 'c' undefined near line 12 column 1 12> [g, r] = angolo([1 2 3],[ 0 0 0]) g = NaN r = NaN 13> [g, r] = angolo([1 2 3],[1 2]) g = 53.301 r = 0.93027 14> help dot 'dot' is a function from the file C:\Octave\Octave3.6.4_gcc4.6.2\lib\octave\3.6.4\oct\i686-pc-mingw32\dot.oct -- Loadable Function: dot (X, Y, DIM) Compute the dot product of two vectors. If X and Y are matrices, calculate the dot products along the first non-singleton dimension. If the optional argument DIM is given, calculate the dot products along this dimension. This is equivalent to `sum (conj (X) .* Y, DIM)', but avoids forming a temporary array and is faster. When X and Y are column vectors, the result is equivalent to `X' * Y'. See also: cross, divergence Additional help for built-in functions and operators is available in the online version of the manual. Use the command 'doc ' to search the manual index. Help and information about Octave is also available on the WWW at http://www.octave.org and via the help@octave.org mailing list. 15> [g, r] = angolo([1 2 3],[1 2]) g = 53.301 r = 0.93027 16> [g, r] = angolo([1 2 3],[1 2 0]) g = 53.301 r = 0.93027 17> c = [3 3 3] c = 3 3 3 18> a=[1] a = 1 19> [g, r] = angolo(a,c) g = 54.736 r = 0.95532 20> [g, r] = angolo([1],[3]) g = 0 r = 0 21> [g, r] = angolo([1 0 0],[3 3 3]) g = 54.736 r = 0.95532 22> edit angolo.m 23> [g, r] = angolo([1 0 0],[3 3]) i vettori devono appartenere allo steeso spazio g = 45 r = 0.78540 24> [g, r] = angolo([1 0 0],[3 3]) i vettori devono appartenere allo steeso spazio g = 45 r = 0.78540 25> [g, r] = angolo([1 0 0],[3 3]) parse error near line 4 of file C:\cygwin\home\achilles\angolo.m syntax error >>> if length(v) ~= length(w) disp('i vettori devono appartenere allo stesso spazio'; return); ^ 25> [g, r] = angolo([1 0 0],[3 3]) parse error near line 4 of file C:\cygwin\home\achilles\angolo.m syntax error >>> if length(v) ~= length(w) (disp('i vettori devono appartenere allo stesso spazio'); return); ^ 25> [g, r] = angolo([1 0 0],[3 3]) i vettori devono appartenere allo stesso spazio g = [](0x0) r = [](0x0) 26> [g, r] = angolo([1 0 0],[0 0 0]) g = NaN r = NaN 27> [g, r] = angolo([1 0 0],[0 0 0]) non ha senso di parlare di un angolo g = [](0x0) r = [](0x0) 28> quit