1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Writing Matlab program for Newton Raphson

  1. Sep 17, 2013 #1
    1. The problem statement, all variables and given/known data

    Two forces P and Q are applied at the end of a screw eye in order to remove the post.
    1.)variations (plots) of P and Q versus (theta) for a given value. R=800 N
    2.) for what value of theta we obtain P=Q?


    2. Relevant equations

    (2*P*sin(theta))*cos(30)+P*cos(theta)-800=0

    3. The attempt at a solution
    I went ahead and found the reaction equations and combined them and got
    (2*P*sin(theta))*cos(30)+P*cos(theta)-800=0

    I need to write this equation as f(theta)=0

    Now using Matlab and trying a newton-raphson method I have to write a program that includes P=400 N to 800N in step sizes of 0.25 N. I need to compute theta for each P.
    Plot P and Q versus theta on same coordinate. .

    This is what I came up with so far for the program.

    x0=400; n=16; eps=0.001; fun=@(tha) 2*p*sin(tha)*cos(30)+p*cos(tha)-800=0; fund=@(x) p*(2*cos(30)*cos(x)-sin(x); nr=(x0,n,eps,fun,fund)
    function nr(x0, n, eps, f, fd)
    func=f(x0); dfunc=fd(x0);
    for i=400:n
    x=x0-func/dfunc;
    fprintf ('%4d %8.4f %8.4f %8.4f\n',i,func, dfunc, x)
    func=f(x); dfunc=fd(x);
    if abs(x-x0) < eps , break, end
    x0=x;
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?