Matlab help. Using Newton Raphson

  • Thread starter Thread starter thekkid33
  • Start date Start date
  • Tags Tags
    Matlab Newton
Click For Summary

Discussion Overview

The discussion revolves around solving a physics problem involving forces applied at a screw eye using the Newton-Raphson method in Matlab. Participants explore the formulation of equations based on trigonometric relationships and the implementation of the Newton-Raphson algorithm to find the angle θ, while also addressing the need for proper coding practices in Matlab.

Discussion Character

  • Homework-related
  • Mathematical reasoning
  • Technical explanation

Main Points Raised

  • One participant presents the equations derived from the forces acting on the screw eye and attempts to formulate a function f(θ) for the Newton-Raphson method.
  • Another participant questions the necessity of using the Newton-Raphson method and suggests that the problem could potentially be solved using trigonometry.
  • A third participant acknowledges the correctness of the functions f(θ) and f'(θ) but points out that the variable p is not defined or passed correctly in the Matlab code, indicating a potential misunderstanding in the implementation.
  • There is a mention of needing to create an M-File for the Matlab setup, highlighting a lack of familiarity with Matlab among some participants.

Areas of Agreement / Disagreement

Participants generally agree on the use of the Newton-Raphson method for solving the problem, but there is some disagreement regarding the necessity of this method versus a simpler trigonometric approach. Additionally, there is uncertainty about the correct implementation of the variable p in the Matlab code.

Contextual Notes

There are limitations regarding the definitions and parameters used in the Matlab functions, particularly the variable p, which is not clearly defined in the context of the provided code. This may affect the clarity and functionality of the proposed solution.

Who May Find This Useful

Students or individuals new to Matlab who are working on physics problems involving forces and require assistance with numerical methods and coding practices.

thekkid33
Messages
2
Reaction score
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
 
Physics news on Phys.org
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?
 
yes i am
 
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.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
1
Views
2K
Replies
15
Views
3K
Replies
2
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K