MATLAB: Error in plotting lyapunov exponent from time series

errorlypunov exponent from time series

Is there any command to plot maximal lyapunov exponent from time series for which i tried my own codes. but still i m in a stage where i get the error:
r =
0
??? Subscript indices must either be real positive integers or logicals.
Error in ==> mlcmainbifr at 10 lyap1=lyap([t,x(:,1)]); pls help me in giving any idea and best suggestions.
kinds regards 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];

Best Answer

Is lyap supposed to be a variable or the function in the Control Toolbox? If the former, you can't index it with t and x because they are real variables, not integers. I can't suggest a fix because I don't know what you are trying to do in enough detail.
You might be able to use Calculation Lyapunov Exponents for ODE from the File Exchange.