필터 지우기
필터 지우기

plotting maximal lyapunov exponent using ode45

조회 수: 4 (최근 30일)
Rizwana Junaid
Rizwana Junaid 2012년 1월 9일
i m in need to plot the lyapunov exponent 'f vs lyapunov,' but i am unable to run the program due to some error in the program. can anyone pls help me to get the plot and any suggestions to make it perfect.
with kind regards
matlab codes:
clc
global f
for f=0.0:0.1:30
f
initialx(1)=0.0100;initialx(2)=0.01;
lyap(1)=.01;
[t,x]=ode45('loreeneq',0:1:500,[initialx(1),initialx(2)]);
lyap1=lyap([t,x(:,1)]);
plot(f,lyap1,'r');
hold on
drawnow
end
xlabel ('f');ylabel('lyap')
--------------------------------------------------------------------------
function dxdt=loreeneq(t,x)
global r
dxdt1=10*(x(2)-x(1));
dxdt2=(r*x(1))-x(2)-(x(1)*x(3));
dxdt3=(x(1)*x(2))-(2.67*x(3));
dxdt=[dxdt1;dxdt2;dxdt3];
  댓글 수: 2
Walter Roberson
Walter Roberson 2012년 1월 9일
It is faster for us if you show us the error message and the line it is complaining about.
Rizwana Junaid
Rizwana Junaid 2012년 1월 10일
sorry i had pasted wrong main file. my code is
matlab codes:
clc
global r
for r=0.0:0.1:30
r
lyap(1)=.01;
[t,x]=ode45('loreeneq',0:1:500,[.01,.01,.01]);
lyap1=lyap([t,x(:,1)]);
plot(r,lyap1,'r');
drawnow
end
xlabel ('r');ylabel('lyap')
----------------------------------------------------------------------
function dxdt=loreeneq(t,x)
global r
dxdt1=10*(x(2)-x(1));
dxdt2=(r*x(1))-x(2)-(x(1)*x(3));
dxdt3=(x(1)*x(2))-(2.67*x(3));
dxdt=[dxdt1;dxdt2;dxdt3];
---------------------------------------------------------
error is:
f =
0
??? Subscript indices must either be real positive integers or logicals.
Error in ==> mlcmainbifr at 10
lyap1=lyap([t,x(:,1)]);

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2012년 1월 9일
In the top portion you have "global f", but you do not use "f" in the other portion. In the bottom portion you have "global r" but you do not use "r" in the other portion.
"global" shares by variable name. There is not just one global variable available. If you want to use the value of f in the bottom routine and you want to pass it via a global then you need to use "global f" in the bottom routine and reference f there instead of r.
If that is what you are trying to do then there are better approaches, which the ode45 documentation links to when it says to see the documentation on "parameterizing functions"

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Computations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by