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: Tue, 22 Feb 2005 12:07:16 +0100
User-agent: Mozilla Thunderbird 0.8 (X11/20041012)

Hello.
Thanks Paul for the response.
If I use your script, I get one the phase space for one initial condition ([1,1] in the example) but I want the phase space for a lot of initial conditions. That is, I want to plot the phase space of the differential equation for initial conditions of the form [x1,x2] (for example):
x1=0+i*0.1
x2=0+i*0.1
for i=0,100.

So, in the above example, I view the phase space for the initial conditions of the form [x1,x2] where 0<=x1<=10 and 0<=x2<=10.

Paul Laub wrote:

Dear Arnau,
I am not sure I understand your question, but the
answer might be simple. Consider these commands
[tt, xx]  = ode45('vdpol', [0 200], [1 1] );

where [1 1] are the initial conditions, and 0 to 200 is
the range of tt (time).
# phase space where time is implicit
plot( xx(:,1), xx(:,2), 'o');

# below, time is the independent variable
plot( tt, xx(:,1), 'o');
plot( tt, xx(:,2), 'o');

In this example, ode45 is an ODE integrator. One such
program is available at http://octave.sourceforge.net/index/index.html Search on the letter "O" and look for "ode45". "vdpol" names an M-file that is written as follows.
   # vdpol.m
   function xdot = vdpol(t, x)
       xdot    = zeros(2,1);
       xdot(1) = x(2);
       xdot(2) = 2 * (1 - x(1).^2) .* x(2) - x(1);
   endfunction

You can replace the Vanderpol equation with your own
ODE system. You will likely have to use your own
(different) parameters for ode45 Paul Laub


On Mon, 21 Feb 2005 17:40:23 +0100, Arnau Mir Torres <address@hidden> wrote:
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
-------------------------------------------------------------





-------------------------------------------------------------
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]