help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: phase portrait


From: Arnau Mir Torres
Subject: Re: phase portrait
Date: Mon, 21 Feb 2005 17:40:23 +0100
User-agent: Mozilla Thunderbird 0.8 (X11/20041012)

Hello.

Thanks Peter for the response.
Excuse me but I don't explain correct.
What I need is to plot the solution (x(t),y(t)) of the differential equation.
I write the following:

function xdot= f (x, t)
       xdot(1)=x(1)-x(1)^2-x(2)^2;
       xdot(2)=-x(2)+2*x(1)*x(2);
endfunction
x0=[0;1];
t=linspace (0,1.1,200)';
x=lsode("f",x0,t);
for i = 1:length(t)
x1(i)=x(i);
x2(i)=x(length(t)+i);
endfor
gset term postscript
gset output "plot.ps"
plot (x1,x2)

In the previous script, I get a graph for every initial condition x0 but I want to plot a lot of graphs in order to obtain how are the solutions of the differential system.



Peter Gawthrop wrote:

Hi Arnau,

try adapting this script. I guess th is x and dth is y in your
notation. You also need to write fun.m to give dx in terms of x=[th;dth] -
equivalent to your f&g functions rolled into one.

Peter.


 dt = 0.1;

 TH = [-1:0.1:1];
 DTH = 5*[-1:0.1:1];

 N = length(TH);
 M = length(DTH);

 i=0;
 THETA = zeros(N*M,1);
 DTHETA = zeros(N*M,1);
 D_THETA = zeros(N*M,1);
 D_DTHETA = zeros(N*M,1);

 for th=TH
   for dth=DTH
     i++;
     x = [th;dth];
     dx = fun(x);
     D_DTHETA(i) =  dx(1);
     D_THETA(i)  =  dx(2);
     THETA(i) = th;
     DTHETA(i) = dth;
   endfor
 endfor


 M = [THETA DTHETA D_THETA*dt D_DTHETA*dt];

 gset nokey
 axis([min(TH), max(TH), min(DTH), max(DTH)]);
 ylabel("$\\dot{\\theta}$")
 xlabel("$\\theta$")
 grid on;
 gplot M with vector


From: Arnau Mir Torres <address@hidden>
Subject: phase portrait
Date: Mon, 21 Feb 2005 15:36:45 +0100

Hello.
I want to plot a phase portrait for a system of differential equations of the form:

xdot= f(t,x,y)
ydot= g(t,x,y)

where t is the independent variable.

I want to plot in the x-y plane coordinates the phase portrait of the previous differential equation.

Somebody can tells me if there exists a package or a script in octave that does it?

Thanks in advance,
Arnau.


--
Arnau Mir Torres
Director Departament Matemàtiques i Informàtica.
Universitat de les Illes Balearss.
Edifici A. Turmeda, Campus de la UIB.
Crta. de Valldemossa, km. 7,5.
07122 Palma de Mallorca.
Baleares.
Spain.
Phone: +34 971 172987
Fax: +34 971 173003
e-mail: address@hidden
web: http://dmi.uib.es/~arnau



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



--
Arnau Mir Torres
Director Departament Matemàtiques i Informàtica.
Universitat de les Illes Balearss.
Edifici A. Turmeda, Campus de la UIB.
Crta. de Valldemossa, km. 7,5.
07122 Palma de Mallorca.
Baleares.
Spain.
Phone: +34 971 172987
Fax: +34 971 173003
e-mail: address@hidden
web: http://dmi.uib.es/~arnau



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]