Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Triple product in matlab

  1. Oct 22, 2018 #1
    1. The problem statement, all variables and given/known data

    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.

    2. Relevant equations
    = M = ( r×F ) ⋅n

    3. The attempt at a solution

    i tried dot(n,cross(r,F)) for the main code but don't know how to plot free body diagram.
     
    Last edited: Oct 22, 2018
  2. jcsd
  3. Oct 22, 2018 #2

    Orodruin

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Gold Member
    2018 Award

    Plot the free body diagram of what?

    This should work. You could also consider
    Code (Matlab M):
    det([r,F,n])
    assuming that r, F, and N are column matrices.
     
  4. Oct 24, 2018 #3
    Moderator's note: two threads were merged, since they deal with the same question.

    1. The problem statement, all variables and given/known data


    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. Relevant equations

    M = ( r× F) ⋅n

    3. 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: Oct 24, 2018
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?