MATLAB: Area of triangle with dot product in matlab

dot product matlab

hi,i was recently introduced in matlab and i face some difficulties,i have to calculate the dot product of three vectors a[4,7], b[6,8] and c [3,12] which form a triangle and then find the angle between them and also the area of the triangle.Could you please give me some ideas??

Best Answer

a = [4,7,0], b = [6,8,0] , c = [3,12,0]
v = [a;b;c]';
v3 = diff([v,v(:,1)],1,2);
ii = [1:3;rem(1:3,3)+1];
l0 = sqrt(sum(v3.^2)));
angles = pi-acos(sum(prod(reshape(v3(:,ii),[3 3 2]),3))./prod(l0(ii)));
Sarea = 1/2*norm(cross(v3(:,1),v3(:,2)));