30-Oct-2013 1> % risolvere il sistema lineare x + 2y = 1, x + 2 y = 5 1> A = [1 2; 1 2] A = 1 2 1 2 2> b = [1; 5] b = 1 5 3> x = A\b x = 0.60000 1.20000 4> inv(A) ans = Inf Inf Inf Inf 5> % Octave: minimizza |A*x-b| 5> x = linspace(-1,2); 6> y1 = -x/2 + 1/2; 7> y2 = -x/2 + 5/2; 8> plot(x,y1, x,y2,'g') 9> grid on; axis equal 10> hold on 11> plot(x,2*x,'r') 12> replot 13> % calcolare l'angolo in radianti e in gradi 13> % compreso tra i vettori (1,1,1) e (1,1,0) 13> % serve il prodotto scalare 13> a = [1,1,1] a = 1 1 1 14> b =[1 1 0] b = 1 1 0 15> p = a * b' p = 2 16> dot(a,b) ans = 2 17> a * b error: operator *: nonconformant arguments (op1 is 1x3, op2 is 1x3) 17> norm(a) ans = 1.7321 18> ans^2 ans = 3.0000 19> sqrt(dot(a,a)) ans = 1.7321 20> % angolo in radianti 20> acos(dot(a,b)/(norm(a) * norm(b))) ans = 0.61548 21> % angoli in gradi 21> ans * 180/pi ans = 35.264 22> hold off 23> quiver3(0,0,0,1,1,1) 24> h = quiver3(0,0,0,1,1,1) h = -18.129 25> set(h, 'color', 'r') 26> set (h,'MaxHeadSize',0.02,'AutoScale','off'); 27> set (h,'MaxHeadSize',0.2,'AutoScale','off'); 28> hold on 29> g = quiver3(0,0,0,1,1,0) g = -23.352 30> set (g, 'color', 'g'); 31> axis equal 32> quit