Matlab help. Using Newton Raphson

You might want to consider defining p explicitly as part of the functions, and then passing x/theta as an argument.f
  • #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.


Homework Equations


The two equations that were found are
1.) Q*sin(30)-P*sin(θ)=0
2.) Q*cos(30)+P*cos(θ)-800=0


The Attempt at a Solution


I combined the 2 equations by first solving (1) in terms of Q=2*P*sin(θ)
then plugged into equation (2) (2*P*sin(θ))*cos(30)+P*cos(θ)-800=0
then got f(θ)=sin(θ)*(√3)*P+P*cos(θ)-800=0
wanted f(θ)=0 as final equation
f'(θ)=P*(2*cos(30)*cos(θ)-sin(θ) (i do not think this is correct though)

Then I have to write a Newton raphson for θ for a given P and solve for θ.
use P=400 to 800 with ΔP=25.
compute θ for each P
once θ is found for each P use equation (1) to find Q
Now plot P and Q for each θ.

I am very new to Matlab. (only introduced to it 2 weeks ago) and i am not to sure how to start. This is what i came up with but it is very confusing to me.

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;
end

**i know there needs to be an M-File for this set up but i am not sure how to do that either.

Thanks in advance for the help
 
  • #2
I know nothing about about Matlab, but I know that this problem can be solved with a bit of simple trigonometry.

Are you supposed to use Newston-Raphson and Matlab to solve this?
 
  • #3
yes i am
 
  • #4
Well, in that case I should say that ##f(\theta)## and ##f'(\theta)## seem correct (except you need to slap a closing bracket onto the latter).

What does not look right, though, is that the functions you define in the program have p in them, yet p is not defined anywhere, nor is it passed as a parameter to them. I think there is some confusion between p and the functions' x/theta argument.
 

Suggested for: Matlab help. Using Newton Raphson

Replies
1
Views
573
Replies
1
Views
719
Replies
5
Views
829
Replies
3
Views
534
Replies
10
Views
886
Replies
12
Views
2K
Back
Top