# Triple product in matlab

## Homework Statement

[/B]
The scalar triple product computes the magnitude of the moment of a force vector about a specified line. It is M = ( r×F ) ⋅n , where is the position vector from the line to the point of application of the force and is a unit vector in the direction of the line. Prompt a user to enter (Fx,Fy ,Fz ), (rx, ry,rz ), and (nx,ny ,nz ); make sure, that is a unit vector and recalculate if necessary; then compute the magnitude for the case and plot the Free Body Diagram. The graph must be formatted and labelled by coding.

## Homework Equations

[/B]= M = ( r×F ) ⋅n

## The Attempt at a Solution

[/B]
i tried dot(n,cross(r,F)) for the main code but don't know how to plot free body diagram.

Last edited:

Related Engineering and Comp Sci Homework Help News on Phys.org
Orodruin
Staff Emeritus
Homework Helper
Gold Member
Plot the free body diagram of what?

dot(n,cross(r,F))
This should work. You could also consider
Matlab:
det([r,F,n])
assuming that r, F, and N are column matrices.

Moderator's note: two threads were merged, since they deal with the same question.

1. Homework Statement

The scalar triple product computes the magnitude of the moment of a force vector about a specified line. It is M = ( r× F) ⋅n , where is the position vector from the line to the point of application of the force and is a unit vector in the direction of the line. MATLAB: Prompt a user to enter (Fx,Fy ,Fz ), (rx, ry, rz), and (nx,ny ,nz ); make sure, that is a unit vector and recalculate if necessary; then compute the magnitude for the case and plot the Free Body Diagram. The graph must be formatted and labelled by coding.

2. Homework Equations

M = ( r× F) ⋅n

## The Attempt at a Solution

clear;
sprinf('\nCalculating the Magnitude of M\n')
r = input ('\n Enter position vector r ');
F = input ('\n Enter Force vector F ');
While l
n = input ('\n Enter direction of the line "n" unit vector ');
N = 0;
for i = 1:1:3
N = N+n(i)^2;
end
N = round (sqrt(N),3);
if N ==1
break
end
sprintf ('\ n Error.n is not a unit vector.\n')
end

M = dot(cross(r,F),n)
M = [ M 0 0 ];

Is this correct code? And I don't know how to plot free body diagram of this code..

Last edited by a moderator: