Having trouble with linregr in matlab

6 views (last 30 days)
Quinton Berry
Quinton Berry on 16 Dec 2020
Answered: Aditya Patil on 24 Dec 2020
So i have this code here with the lyapunov experiment and im trying to use linear regression of linearized data with linregr to find the numeric value of the lyapunov exponet with the time interval (7.0-17.0) and it says first i need to find the array indices according to those time values but i do not know how to find the array indices or how to implement linear regression correctly to find the exponet.
function yp = lorenz_attractor(t,y)
yp = [10 * (y(2)-y(1)); 28*y(1) - y(1)*y(3) - y(2); ...
y(1)*y(2) - (8/3)*y(3)];
tspan = [0 30]; y0 = [5 5 5]; y00 = [5.00001 5 5];
[t1, y1] = ode45(@lorenz_attractor,tspan,y0);
[t2, y2] = ode45(@lorenz_attractor,tspan,y00);
figure(1)
plot(t1,y1(:,3),t2,y2(:,3),'--')
title('y_3(t) for y(0)=[5 5 5] (solid) and y(0)=[5.00001 5 5] (dashed)')
y21 = interp1(t2,y2,t1);
figure(2)
v=log(abs(y21(:,3)- y1(:,3)));
plot(t1,v)
title('logarithm of separation of the two y_3(t) solutions')

Answers (1)

Aditya Patil
Aditya Patil on 24 Dec 2020
You can use fitlm for linear regression. You can check the documentation for examples.

Community Treasure Hunt

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

Start Hunting!