필터 지우기
필터 지우기

Jacobain with 3 functions

조회 수: 2 (최근 30일)
am
am 2019년 3월 27일
편집: madhan ravi 2019년 3월 27일
Hello,
Can someone help me to see what is wrong with my jacobian?
I reviewed it several time byt matlab still says there is a syntax error.
Additionally, why jacobian(f,x) does not work?
f=@(x) [3*x(1) - cos(x(2)*x(3)) - 3/2;
4*x(1)^2 - 625*x(2)^2 + 2*x(3) - 1;
20*x(3)^3 + exp(-1*(x(1)*x(2))) + 9]
J=@(x) [3, -1*(x(3)*cos(x(2)*x(3))), -1*(x(2)*cos(x(2)*x(3)));
8*x(1) , 1250*x(2), 2;
-1*(x(2)exp(-x(1)*x(2))), -1*(x(1)exp(-x(1)*x(2))), 20]
  댓글 수: 2
am
am 2019년 3월 27일
I would also like to understand what is wrong with my syntax?
J=@(x) [3, -1.*(x(3).*cos(x(2)*x(3))), -1.*(x(2).*cos(x(2)*x(3)));
8*x(1) , 1250*x(2), 2;
-1*(x(2)exp(-x(1)*x(2))), -1*(x(1)exp(-x(1)*x(2))), 20]
madhan ravi
madhan ravi 2019년 3월 27일
Correct syntax would be:
J=@(x) [3, -1.*(x(3).*cos(x(2)*x(3))), -1.*(x(2).*cos(x(2)*x(3)));
8*x(1) , 1250*x(2), 2;
-1*(x(2)*exp(-x(1)*x(2))), -1*(x(1)*exp(-x(1)*x(2))), 20]

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

채택된 답변

madhan ravi
madhan ravi 2019년 3월 27일
편집: madhan ravi 2019년 3월 27일
https://in.mathworks.com/help/symbolic/jacobian.html - the function has to have symbolic arguments as mentioned in the link above , where as what you created was a function handle (@(x)).
x = sym('x',[1 3]);
syms(x) % the reason I used this is even you can access the elements of the vector x as like x1 or x(1) unlike x = sym('x',[1,3]) where you can only access the elements as x(1) but not as x1!
f= [3*x(1) - cos(x(2)*x(3)) - 3/2;
4*x(1)^2 - 625*x(2)^2 + 2*x(3) - 1;
20*x(3)^3 + exp(-1*(x(1)*x(2))) + 9]
jacobian(f,x)
if you type
>> which jacobian -all
/Applications/MATLAB_R2018b.app/toolbox/symbolic/symbolic/@sym/jacobian.m % sym method
>>
It shows that jacobian() belongs to symbolic math toolbox.
  댓글 수: 4
am
am 2019년 3월 27일
thank you <3
madhan ravi
madhan ravi 2019년 3월 27일
편집: madhan ravi 2019년 3월 27일
If you just want to do the operation => J(x)\f(x) then
x = sym('x',[1 3]);
f(x) = [3*x(1) - cos(x(2)*x(3)) - 3/2 ;...
4*x(1)^2 - 625*x(2)^2 + 2*x(3) - 1 ;...
20*x(3)^3 + exp(-1*(x(1)*x(2))) + 9];
J(x) = [3 , -1.*(x(3).*cos(x(2)*x(3))), -1.*(x(2).*cos(x(2)*x(3))) ;...
8*x(1) , 1250*x(2) , 2 ;...
-1*(x(2)*exp(-x(1)*x(2))), -1*(x(1)*exp(-x(1)*x(2))) , 20 ];
Calculation = J\f;
Calculation(2,4,5)
% ^^^^^---- example values of x1 , x2 and x3 , this line of code indicates now you can substitute 3 values in the place of x1, x2 and x3
% you then double the result using double() for instance
double(Calculation(2,4,5))

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by