File: ex3.m

package info (click to toggle)
casadi 3.7.0%2Bds2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,964 kB
  • sloc: cpp: 114,229; python: 35,462; xml: 1,946; ansic: 859; makefile: 257; sh: 114; f90: 63; perl: 9
file content (27 lines) | stat: -rw-r--r-- 463 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
% MATLAB/Octave
import casadi.*

% Formulate the ODE
x=SX.sym('x',2);
p=SX.sym('p');
z=1-x(2)^2;
f=[z*x(1)-x(2)+p;x(1)];
dae=struct('x',x,'p',p,...
           'ode',f);

% Create solver instance
op=struct('t0',0,'tf',1);
F=integrator('F',...
      'cvodes',dae,op);

% Solve the problem
r=F('x0',[0,1],'p',0.1);
disp(r.xf)

% Create Jacobian function
D=F.factory('D',...
 {'x0','p'},{'jac:xf:x0'});

% Solve the problem
r=D('x0',[0,1],'p',0.1);
disp(r.jac_xf_x0)