From: Sean on
"Sean " <sean.dewolski(a)nospamplease.umit.maine.edu> wrote in message <hsead5$oit$1(a)fred.mathworks.com>...
> "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!

Also, according to this website:
http://planetmath.org/encyclopedia/LorenzEquation.html
Your lorenz equation is wrong. It might be a different variation of it, but running it with this equation provided meaningful plots at higher values!

should be:
function dx=lorenzeqs(t,x)
sigma=10;
b=8/3;
dx=zeros(3,1);
dx(1)=sigma*(x(2)-x(1));
dx(2)=x(1)*(28-x(3))-x(2);
dx(3)=x(1)*x(2)-b*x(3);
end
From: Roman Tolmachev on
> > 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!
>
> Also, according to this website:
> http://planetmath.org/encyclopedia/LorenzEquation.html
> Your lorenz equation is wrong. It might be a different variation of it, but running it with this equation provided meaningful plots at higher values!
>
> should be:
> function dx=lorenzeqs(t,x)
> sigma=10;
> b=8/3;
> dx=zeros(3,1);
> dx(1)=sigma*(x(2)-x(1));
> dx(2)=x(1)*(28-x(3))-x(2);
> dx(3)=x(1)*x(2)-b*x(3);
> end

Thank you guys, I made a really stupid mistake in rewriting equations and didn't checked it. I'll try new system as soon as possible.
Thank you again and best wishes,
Roman.
From: OH on
You should be
function dx=lorenzeqs(t,x)
sigma=10;
b=8/3;
dx=zeros(3,1);

dx(1)=sigma*(x(2)-x(1));
dx(2)=x(1)*(28-x(3))-x(2);
dx(3)=x(1)*x(2)-b*x(3);

Usually, ODE function do not use end statements.
From: Walter Roberson on
OH wrote:
> You should be
> function dx=lorenzeqs(t,x)
> sigma=10; b=8/3;
> dx=zeros(3,1);
>
> dx(1)=sigma*(x(2)-x(1));
> dx(2)=x(1)*(28-x(3))-x(2);
> dx(3)=x(1)*x(2)-b*x(3);
>
> Usually, ODE function do not use end statements.

That's an interesting remark. Is there any reason why an ODE function should
*not* use an 'end' statement?
From: OH on
I thinks the reason why ode functions do not use end statements.

1. not fortran compiler
As far as I know about fortran, end statements need to designate the end of program. But, Matlab do not need those command mendatory.

2. ode function related to odesolver command and do not open any function like for, if statement.

How do you think about my comment?

(for several weeks, I stick to solve ode45 function on my marine snow aggregation function. )
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: line by line subtraction
Next: Wavrecord