% risolvere il sistema lineare x + 2y = 1, x + 2 y = 5
A = [1 2; 1 2]
b = [1; 5]
x = A\b
inv(A)
% Octave: minimizza |A*x-b|
x = linspace(-1,2);
y1 = -x/2 + 1/2;
y2 = -x/2 + 5/2;
plot(x,y1, x,y2,'g')
grid on; axis equal
hold on
plot(x,2*x,'r')
replot
% calcolare l'angolo in radianti e in gradi
% compreso tra i vettori (1,1,1) e (1,1,0)
% serve il prodotto scalare
a = [1,1,1]
b =[1 1 0]
p = a * b'
dot(a,b)
a * b
norm(a)
ans^2
sqrt(dot(a,a))
% angolo in radianti
acos(dot(a,b)/(norm(a) * norm(b)))
% angoli in gradi
ans * 180/pi
hold off
quiver3(0,0,0,1,1,1)
h = quiver3(0,0,0,1,1,1)
set(h, 'color', 'r')
set (h,'MaxHeadSize',0.02,'AutoScale','off');
set (h,'MaxHeadSize',0.2,'AutoScale','off');
hold on
g = quiver3(0,0,0,1,1,0)
set (g, 'color', 'g');
axis equal
quit
# Octave 3.6.4, Wed Oct 30 17:03:51 2013 W. Europe Standard Time <unknown@achilles-TOSH>
