I'm trying to solve a system of 6 non linear equations using Newton Raphson Method. I defined my equations with 6 inputs (given as initial guesses) and the function returns value after solving it with the inputs.
Then, while trying to calculate Jacobians,
W=jacobian([f(1),f(2),f(3),f(4),f(5),f(6)],[theta,phi,omega,V,alpha1,beta1]);
Jacobian is evaluated and I get the partial derivatives accordingly.
But when I tried calling a function that calculates Jacobian W, with my initial guess. It does not give me a value, rather the partial derivative itself.
function X=jaccalc(input,W);
theta=input(1)
phi=input(2)
omega=input(3);
V=input(4);
alpha1=input(5);
beta1=input(6);
% other variables were also defined
for i=1:6
X(i)=W(i); %I tried assigning a matrix X in hopes that it would calculate the value with the inputs.
end
end
Kindly help me out. And any advice on making the code efficient is also much appreciated

답변 (1개)

Stephen23
Stephen23 2019년 2월 20일

0 개 추천

You will need to use subs:
The loop is superfluous.

댓글 수: 2

Thank you Stepehen, that did work. But I'm getting values that arent decimals, rather a combination of two huge numbers, when divided gives the numerical value.
-23005294093609302249/14411518807585587200 , (9*pi)/10 - (97*cos(10)^2)/250
Thank you for prompt reply again.
Walter Roberson
Walter Roberson 2019년 2월 20일
That is your jacobian. Decimal would only be an approximation of the jacobian. But if you really want that then double() the answer you are getting .

댓글을 달려면 로그인하십시오.

질문:

2019년 2월 19일

댓글:

2019년 2월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by