23-Oct-2013 1> A = [1 -2; 5 4; -3 0] A = 1 -2 5 4 -3 0 2> B =[ -3 5 0 1; 2 -7 4 -1] B = -3 5 0 1 2 -7 4 -1 3> C = A * B C = -7 19 -8 3 -7 -3 16 1 9 -15 0 -3 4> B * A error: operator *: nonconformant arguments (op1 is 2x4, op2 is 3x2) 4> a = [1 0; 0 0] a = 1 0 0 0 5> b = [0 1; 0 1] b = 0 1 0 1 6> a * b ans = 0 1 0 0 7> b * a ans = 0 0 0 0 8> % divisori dello zero 8> zeros(2,2) ans = 0 0 0 0 9> zeros(4,1) ans = 0 0 0 0 10> % scambiare righe e colonne (e colonne e righe); trasposta 10> A A = 1 -2 5 4 -3 0 11> A' % matrrice trasposta di A ans = 1 5 -3 -2 4 0 12> zero = zeros(4,1) zero = 0 0 0 0 13> zero' ans = 0 0 0 0 14> v = [1+3i, -3+4i] v = 1 + 3i -3 + 4i 15> v' % trasposta coniugata ans = 1 - 3i -3 - 4i 16> v.' % trasposta (senza passare al complesso coniugato) ans = 1 + 3i -3 + 4i 17> A A = 1 -2 5 4 -3 0 18> A^2 error: for A^b, A must be a square matrix 18> A.^2 ans = 1 4 25 16 9 0 19> 19> A + B error: operator +: nonconformant arguments (op1 is 3x2, op2 is 2x4) 19> E = [1 -7; 5 -8; -5 1] E = 1 -7 5 -8 -5 1 20> size(A) ans = 3 2 21> size(E) ans = 3 2 22> size(size(E)) ans = 1 2 23> A + E ans = 2 -9 10 -4 -8 1 24> A - E ans = 0 5 0 12 2 -1 25> 3*A ans = 3 -6 15 12 -9 0 26> 3*A - 5*E ans = -2 29 -10 52 16 -5 27> % definire funzioni 27> f = inline('x.^2', 'x') f = f(x) = x.^2 28> x error: 'x' undefined near line 28 column 1 28> 'x' ans = x 29> f(-4) ans = 16 30> f([-2 -1 0 1 2]) ans = 4 1 0 1 4 31> f([-2 -1 ; 1 2]) ans = 4 1 1 4 32> g = inline('a*x.^2', 'a', 'x') g = f(a, x) = a*x.^2 33> g(5,3) ans = 45 34> % anonymous function; function handle @ 34> h = @(x) 1./x h = @(x) 1 ./ x 35> h(4) ans = 0.25000 36> edit nostra_funzione.m 37> pwd ans = C:\cygwin\home\achilles 38> help nostra_funzione 'nostra_funzione' is a function from the file C:\cygwin\home\achilles\nostra_funzione.m nostra_funzione(x) calcola sin x / x 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. 39> x = linspace(-2*pi,2*pi); 40> plot(x, nostra_funzione(x)); 41> quit