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

Antworten (1)

Stephen23
Stephen23 am 20 Feb. 2019

0 Stimmen

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

2 Kommentare

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 am 20 Feb. 2019
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 .

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 19 Feb. 2019

Kommentiert:

am 20 Feb. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by