How to use jacobian in a specific case

1 Ansicht (letzte 30 Tage)
John Miller
John Miller am 27 Jul. 2012
Hello,
I have following code:
function dydt = fun_eval(t,x,a)
global x0g
f1 = [((119*x(2))/27 + (2981766797354441*exp((500*x(1))/13))/309485009821345068724781056 + (8882160727547769*exp((500*x(2))/13))/2475880078570760549798248448 - 24758800785740341793088867777/2475880078570760549798248448);
(x(1) + (4901737476034079*exp((500*x(1))/13))/4951760157141521099596496896 + (6669030579638201*exp((500*x(2))/13))/9903520314283042199192993792 - 18547597874385838245692255223/9903520314283042199192993792)];
G=[(x(1)-x0g(1)),0;0,(x(2)-x0g(2))];
f=G*f1;
dydt1 = t*f + (1-t)*(x-x0g + f);
J = jacobian(dydt1,x); %Here is the problem but I don't how to change dydt1
Ji=inv(J);
f_d=diff(dydt1,t);
dydt=-Ji*f_d;
ERROR:
Undefined function 'jacobian' for input arguments of type 'double'.
Error in ProbSE31>fun_eval (line 79)
J = jacobian(dydt1,x);
Error in cjac (line 32)
j(:,i) = feval(odefile, 0, x2, p{:})-feval(odefile, 0, x1, p{:});
Error in init_EP_EP (line 78)
jac = cjac(eds.func,eds.Jacobian,x,num2cell(p),eds.ActiveParams);
Error in MainRealSE3 (line 80)
[x0,vO] = init_EP_EP(@ProbSE31,x0g+dx, p, ap);
  1 Kommentar
Sargondjani
Sargondjani am 27 Jul. 2012
it looks like 'jacobian' only works for symbolic expressions... i have no experience with them, but you would have to declare variables as symbols (as in the example in the documentation).
or if you are fine with estimating the jacobian with finite differences you could also use the 'jacobianest' function from the file exchange
(or you could derive the analytical jacobian yourself. this doesnt look too difficult at first glance)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by