Writing Matlab program for Newton Raphson

In summary, the conversation discusses the application of two forces, P and Q, at the end of a screw eye to remove a post. The homework statement includes finding plots of P and Q versus theta for a given value of R=800 N, as well as determining the value of theta for which P=Q. The homework equations involve combining reaction equations and writing them in the form of f(theta)=0. The attempt at a solution involves using the Newton-raphson method in Matlab to compute theta for P values ranging from 400 N to 800 N in increments of 0.25 N and plotting P and Q versus theta on the same coordinate. The code provided may be used for this purpose, but its accuracy and completeness are
  • #1
thekkid33
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;
 
Physics news on Phys.org
  • #2
endend I am not sure if this is the right way to go about it or if I am missing something. I would really appreciate some help!
 

1. What is the Newton Raphson method in Matlab?

The Newton Raphson method is a numerical method used for finding the roots of a given function. It is an iterative process that uses linear approximation to approach the root of a function. In Matlab, it can be implemented as a program to find the root of a given equation.

2. How does the Newton Raphson method work in Matlab?

The Newton Raphson method in Matlab works by starting with an initial guess for the root of a function. It then uses the derivative of the function to calculate the slope of the function at that point. This slope is used to find a better approximation of the root, and the process is repeated until a desired level of accuracy is achieved.

3. What are the advantages of using the Newton Raphson method in Matlab?

One of the main advantages of the Newton Raphson method in Matlab is that it can find the root of a function with a high degree of accuracy. It also converges quickly, meaning that it takes fewer iterations to reach the desired level of accuracy compared to other numerical methods.

4. What are the limitations of using the Newton Raphson method in Matlab?

The Newton Raphson method in Matlab may fail to find a root if the initial guess is too far from the actual root or if the function has multiple roots. It also requires the calculation of the derivative of the function, which may be complex or time-consuming for certain functions.

5. How can I use the Newton Raphson method in Matlab to solve a real-world problem?

The Newton Raphson method in Matlab can be used to solve various real-world problems that involve finding roots of equations. For example, it can be used to find the intersection of two curves in a graph or to solve optimization problems by finding the minimum or maximum of a function. It is a useful tool for scientists and engineers in various fields such as physics, economics, and engineering.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
5K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
3K
  • Introductory Physics Homework Help
Replies
4
Views
816
  • Engineering and Comp Sci Homework Help
Replies
12
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
21
Views
2K
Replies
8
Views
2K
Back
Top