Scilab Function
Last update : 18/05/2014
portrait - 2 dimensional phase portrait.
Calling Sequence
- []=portrait(f,[odem,xdim,npts,farrow,pinit])
Parameters
-
f: a Scilab external which gives the field of the dynamical system. Hence it can be a macro name which computes the field at time t and point x [y]=f(t,x,[u]) or a list list(f1,u1) where f1 is a macro of type [y]=f1(t,x,u) or a character string. The macro can be used to simulate a continuous or discrete system and in case of discrete system the second parameter must be set to 'discrete'
-
options: The other parameters are optional. If omitted they will be asked interactively
-
odem: gives the integration method to use. The value "default" can be used, otherwise see ode for a complete set of possibilities
-
xdim: [xmin,ymin,xmax,ymax] the boundaries of the graphic frame.
-
npts: a vector of size 2 [number-of-points,step] gives the step
for integration and the number of requested points. The solution
will be calculated and drawn for
time=0:step:(step*[number-of-points])
-
farrow: a string 't' or 'f' to display arrows or not on trajectory.
-
pinit: initial values for integration. A set of initial points can be given in a matrix
pinit = [x0(1), x1(1),...., xn(1)
x0(2), x1(2),...., xn(2)
x0(3), x1(3),...., xn(3)].
Description
Interactive integration and display of a 2 dimensional phase portrait
of a dynamical system dx/dt=f(t,x,[u]) (where u is an optional parameter )
Examples
//Interactive
a=rand(2,2)
deff('[ydot]=l_s(t,y)','ydot=a*y')
portrait(l_s)
//predator prey
function xd=predprey(t,x)
xd(1)=-3*x(1)+4*x(1)^2-x(1)*x(2)/2-x(1)^3;
xd(2)=-2.1*x(2)+x(1)*x(2);
endfunction
bound=[-1,-1,4,4];
nrect=12;
x=linspace(bound(1),bound(3),nrect);
y=linspace(bound(2),bound(4),nrect);
x0=[];
for i=1:size(x,'*')
for j=1:size(y,'*')
x0=[x0;x(i),y(j)];
end
end
portrait(predprey,"default",[-1,-1,4,4],[3000,0.01],'f',x0');
See Also
ode,