clc;
clear;
close all;
% [T,Y]=ode45('chua',[0,300],[0.1,0.1,0.1]);%解微分方程
[T,Y]=ode45('chua',0:0.01:10,[0 0.3 0 0]);
figure(1);
plot3(Y(:,1),Y(:,2),Y(:,3),'-');
xlabel('x'); ylabel('y'); zlabel('z');
title('x-y-z立体相图');
figure(2);
plot(Y(:,1),Y(:,2),'-');
xlabel('x');ylabel('y');
title('x-y相图')
figure(3);
plot(Y(:,2),Y(:,3),'-');
xlabel('y');ylabel('z');
title('y-z相图')
子函数:
function dy = chua(t,y)
% dy=zeros(3,1);
global alpha beta gamma u a b ;
alpha=8;beta=12.5;gamma=1;a=-0.8;b=0.3;
M(u)=(a+b).*(abs(u)>=1)+(a-b).*(abs(u)<1);
dy=[alpha*(y(2)-y(1)-gamma*M(u)*y(1));
y(1)-y(2)+y(3);
-beta*y(2);
y(1)];
end