From: Roman Tolmachev on
Hello everyone,
I need your help with such a question: I try to plot the solution for Lorenz system, but find that matlab's performance is extremely slow. I started the program yesterday at 19.00 and it is still calculating. I tried matlabpool to use second core, but it seems no result. Is it ok that such a simple program requires so much time? What would you do in that case?
Thanks in advance, the code is below.

function lorplane(p1)
global r sigma b
sigma=10; b=8/3;
r=p1;
options=odeset('AbsTol',1e-6,'RelTol',1e-4);
xinit=sqrt(b*(r-1));
yinit=sqrt(b*(r-1));
zinit=(r-1);
[T,X]=ode45(@lorenzeqs,[0 50],[xinit yinit zinit],options);
plot(X(:,1),X(:,3))

function dx=lorenzeqs(t,x);
global r;
sigma=10; b=8/3;
dx=zeros(3,1);
dx(1)=sigma*(x(2)-x(1));
dx(2)=r*x(1)-x(2)-x(1)*x(3);
dx(3)=x(1)*x(3)-b*x(3);
From: Sean on
"Roman Tolmachev" <tolmachevroman(a)gmail.com> wrote in message <hsduar$ff4$1(a)fred.mathworks.com>...
> Hello everyone,
> I need your help with such a question: I try to plot the solution for Lorenz system, but find that matlab's performance is extremely slow. I started the program yesterday at 19.00 and it is still calculating. I tried matlabpool to use second core, but it seems no result. Is it ok that such a simple program requires so much time? What would you do in that case?
> Thanks in advance, the code is below.
>
> function lorplane(p1)
> global r sigma b
> sigma=10; b=8/3;
> r=p1;
> options=odeset('AbsTol',1e-6,'RelTol',1e-4);
> xinit=sqrt(b*(r-1));
> yinit=sqrt(b*(r-1));
> zinit=(r-1);
> [T,X]=ode45(@lorenzeqs,[0 50],[xinit yinit zinit],options);
> plot(X(:,1),X(:,3))
>
> function dx=lorenzeqs(t,x);
> global r;
> sigma=10; b=8/3;
> dx=zeros(3,1);
> dx(1)=sigma*(x(2)-x(1));
> dx(2)=r*x(1)-x(2)-x(1)*x(3);
> dx(3)=x(1)*x(3)-b*x(3);


What are you using for p1? It takes fractions of a second to run on any number <= 1.4. Apparently it diverges above that.
From: Roman Tolmachev on
"Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <hse58m$t0l$1(a)fred.mathworks.com>...
> "Roman Tolmachev" <tolmachevroman(a)gmail.com> wrote in message <hsduar$ff4$1(a)fred.mathworks.com>...
> > Hello everyone,
> > I need your help with such a question: I try to plot the solution for Lorenz system, but find that matlab's performance is extremely slow. I started the program yesterday at 19.00 and it is still calculating. I tried matlabpool to use second core, but it seems no result. Is it ok that such a simple program requires so much time? What would you do in that case?
> > Thanks in advance, the code is below.
> >
> > function lorplane(p1)
> > global r sigma b
> > sigma=10; b=8/3;
> > r=p1;
> > options=odeset('AbsTol',1e-6,'RelTol',1e-4);
> > xinit=sqrt(b*(r-1));
> > yinit=sqrt(b*(r-1));
> > zinit=(r-1);
> > [T,X]=ode45(@lorenzeqs,[0 50],[xinit yinit zinit],options);
> > plot(X(:,1),X(:,3))
> >
> > function dx=lorenzeqs(t,x);
> > global r;
> > sigma=10; b=8/3;
> > dx=zeros(3,1);
> > dx(1)=sigma*(x(2)-x(1));
> > dx(2)=r*x(1)-x(2)-x(1)*x(3);
> > dx(3)=x(1)*x(3)-b*x(3);
>
>
> What are you using for p1? It takes fractions of a second to run on any number <= 1.4. Apparently it diverges above that.

Thanks for attention. According to the Lorenz system features, p1 can be bigger than 1.4, e.g. 13 or 24 and it should lead to different results, and it is my task actually to test different p1 from 10 and higher to obtain these results. I thought about Euler iterations method here, but I am not sure it will be faster...
From: Sean on
"Roman Tolmachev" <tolmachevroman(a)gmail.com> wrote in message <hse9h0$sh9$1(a)fred.mathworks.com>...
> "Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <hse58m$t0l$1(a)fred.mathworks.com>...
> > "Roman Tolmachev" <tolmachevroman(a)gmail.com> wrote in message <hsduar$ff4$1(a)fred.mathworks.com>...
> > > Hello everyone,
> > > I need your help with such a question: I try to plot the solution for Lorenz system, but find that matlab's performance is extremely slow. I started the program yesterday at 19.00 and it is still calculating. I tried matlabpool to use second core, but it seems no result. Is it ok that such a simple program requires so much time? What would you do in that case?
> > > Thanks in advance, the code is below.
> > >
> > > function lorplane(p1)
> > > global r sigma b
> > > sigma=10; b=8/3;
> > > r=p1;
> > > options=odeset('AbsTol',1e-6,'RelTol',1e-4);
> > > xinit=sqrt(b*(r-1));
> > > yinit=sqrt(b*(r-1));
> > > zinit=(r-1);
> > > [T,X]=ode45(@lorenzeqs,[0 50],[xinit yinit zinit],options);
> > > plot(X(:,1),X(:,3))
> > >
> > > function dx=lorenzeqs(t,x);
> > > global r;
> > > sigma=10; b=8/3;
> > > dx=zeros(3,1);
> > > dx(1)=sigma*(x(2)-x(1));
> > > dx(2)=r*x(1)-x(2)-x(1)*x(3);
> > > dx(3)=x(1)*x(3)-b*x(3);
> >
> >
> > What are you using for p1? It takes fractions of a second to run on any number <= 1.4. Apparently it diverges above that.
>
> Thanks for attention. According to the Lorenz system features, p1 can be bigger than 1.4, e.g. 13 or 24 and it should lead to different results, and it is my task actually to test different p1 from 10 and higher to obtain these results. I thought about Euler iterations method here, but I am not sure it will be faster...

Try some of the other ode functions ode15s, ode23t etc. I tried these two and it spit back a result. The result appeared to be meaningless (10^162) but that's what it gave. Maybe there's something wrong with your Lorenz equation. Apparently there is some stiffness in this equation. I'm not familiar with it.

Good Luck!
From: Steven Lord on

"Roman Tolmachev" <tolmachevroman(a)gmail.com> wrote in message
news:hsduar$ff4$1(a)fred.mathworks.com...
> Hello everyone,
> I need your help with such a question: I try to plot the solution for
> Lorenz system, but find that matlab's performance is extremely slow. I
> started the program yesterday at 19.00 and it is still calculating. I
> tried matlabpool to use second core, but it seems no result. Is it ok that
> such a simple program requires so much time? What would you do in that
> case?

I tried running this for p1 = 11 with one small change -- I added one option
to your options structure.

options=odeset('AbsTol',1e-6,'RelTol',1e-4, 'OutputFcn', @odeplot);

When I did this I saw that one of the components of your system, x(3), went
to zero and remained there fairly quickly. The other two components dropped
like a stone; when I stopped the execution around t = 3, they were down in
the -2e4 range and still falling. That is likely the cause of the "slow
performance".

I would confirm that the equations you included in your function are
correct. Doing a quick comparison with those in the Wikipedia page:

http://en.wikipedia.org/wiki/Lorenz_attractor

leads me to believe that your second and third equations are not correct.
When I replaced your equations with those in that page I got something
closer to what I expected in a fraction of a second.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ


 |  Next  |  Last
Pages: 1 2 3
Prev: line by line subtraction
Next: Wavrecord