Writing Matlab program for Newton Raphson

  • Thread starter thekkid33
  • Start date
  • #1
4
0

Homework Statement



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?


Homework Equations



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

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;
 

Answers and Replies

Related Threads on Writing Matlab program for Newton Raphson

  • Last Post
Replies
3
Views
1K
Replies
21
Views
2K
  • Last Post
Replies
7
Views
6K
  • Last Post
Replies
20
Views
16K
  • Last Post
Replies
9
Views
6K
Replies
1
Views
2K
Replies
5
Views
8K
  • Last Post
Replies
2
Views
945
  • Last Post
Replies
2
Views
2K
Top