📄 chap2_ex7_3.m
字号:
% Chap2_Ex7_3.m
clc, clear all, close all
m=1; k=2; c=0.5; F0=3;
T=0.001;
tfinal=15;
nfinal=round(tfinal/T);
max_x1=0; max_x2=0; min_x1=0; min_x2=0;
t=0:T:tfinal-T;
x10(1)=-1; x20(1)=-5;
x10(2)=-2; x20(2)=15;
x10(3)=2; x20(3)=5;
x10(4)=5; x20(4)=-20;
for i=1:4
x1(1)=x10(i); x2(1)=x20(i);
for n=1:nfinal-1
x1(n+1)=x1(n)+T*x2(n);
x2(n+1)=x2(n)-(T/m)*(k*x1(n)+(c*(x1(n)^2)-F0)*x2(n));
end % n
M1=max(x1); M2=max(x2);
if M1>max_x1
max_x1=M1;
end
if M2>max_x2
max_x2=M2;
end
m1=min(x1); m2=min(x2);
if m1<min_x1
min_x1=m1;
end
if m2<min_x2
min_x2=m2;
end
figure(1)
plot(x1,x2)
axis([1.1*min_x1 1.1*max_x1 1.1*min_x2 1.1*max_x2])
hold on
plot(x10(i),x20(i),'.r','MarkerSize',10)
end % i
xlabel('\itx_{\rm1}','FontSize',11)
ylabel('\itx_{\rm2}','FontSize',11)
title('Nonlinear System with Limit Cycle','FontSize',11)
text(-5.5,24,'\itm \rm= 1, \itk \rm= 2, \itc \rm= 0.5, \itF_{\rm0} = 3','FontSize',11)
text(-1.5,-3,'(-1,-5)','FontSize',11)
text(-3.5,15,'(-2,15)','FontSize',11)
text(1,5,'(2,5)','FontSize',11)
text(3.5,-20,'(5,-20)','FontSize',11)
figure(2)
subplot(2,1,1)
plot(t,x1)
hold on
plot([0 15],[0 0],'k')
plot([0 0],[-0.5 0.5],'k')
axis([-1 16 -6 6])
ylabel('\itx_{\rm1}','FontSize',11)
title('\itx_{\rm1} vs \itt \rm for System with Limit Cycle Starting at (5,-20)','FontSize',11)
subplot(2,1,2)
plot(t,x2)
hold on
plot([0 15],[0 0],'k')
plot([0 0],[-2 2],'k')
axis([-1 16 -22 18])
xlabel('\itt','FontSize',11)
ylabel('\itx_{\rm2}','FontSize',11)
title('\itx_{\rm2} vs \itt \rm for System with Limit Cycle Starting at (5,-20)','FontSize',11)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -