📄 chap2_figs7_11and12.m
字号:
% Chap2_Figs7_11and12.m
clc, clear all, close all
wn=1;
t=linspace(0,6*pi/wn,1000);
x0(1)=0.1; x0_dot(1)=0.1;
x0(2)=-0.3; x0_dot(2)=0.25;
x0(3)=-0.4; x0_dot(3)=-0.5;
x0(4)=0.85; x0_dot(4)=-0.2;
for i=1:4
figure(1)
hold on
x=x0(i)*cos(wn*t)+(x0_dot(i)/wn)*sin(wn*t);
xdot=-wn*x0(i)*sin(wn*t)+x0_dot(i)*cos(wn*t);
switch i
case 1
plot(x,xdot,'b')
plot(x0(i),x0_dot(i),'.b','MarkerSize',12)
case 2
plot(x,xdot,'r')
plot(x0(i),x0_dot(i),'.r','MarkerSize',12)
case 3
plot(x,xdot,'g')
plot(x0(i),x0_dot(i),'.g','MarkerSize',12)
case 4
plot(x,xdot,'k')
plot(x0(i),x0_dot(i),'.k','MarkerSize',12)
end
axis equal
axis([-1.1 1.1 -1.1 1.1])
figure(2)
subplot(2,1,1)
hold on
switch i
case 1
plot(t,x,'b')
text(0.22,0.26,'a')
case 2
plot(t,x,'r')
text(2.35,0.52,'b')
case 3
plot(t,x,'g')
text(3.9,0.78,'c')
case 4
plot(t,x,'k')
text(5.9,1,'d')
end
axis([0 12 -1 1.1])
ylabel('\itx','FontSize',11)
title('Sustained Oscillations of \itx \rmfor Undamped Second Order Systems','FontSize',11)
subplot(2,1,2)
hold on
switch i
case 1
plot(t,xdot,'b')
text(1.5,-0.25,'a')
case 2
plot(t,xdot,'r')
text(3.9,-0.55,'b')
case 3
plot(t,xdot,'g')
text(5.5,-0.77,'c')
case 4
plot(t,xdot,'k')
text(7.5,-1.04,'d')
end
axis([0 12 -1.15 1])
xlabel('\itt','FontSize',11)
ylabel('d\itx\rm/dt','FontSize',11)
title('Sustained Oscillations of d\itx\rm/dt \rmfor Undamped Second Order Systems','FontSize',11)
end
figure(1)
plot([-1 1],[0 0],'k')
plot([0 0],[-1 1],'k')
xlabel('\itx','FontSize',11)
ylabel('d\itx\rm/dt','FontSize',11)
title('State Trajectories of Undamped Second Order Systems','FontSize',11)
text(0.25,1.0,'\omega_{\itn} \rm= 1 rad/sec','FontSize',11)
text(0.15,-1,'Initial State: \itx\rm(0), \itx\rm(0)','FontSize',11)
plot([0.1],[-1],'.k','MarkerSize',12)
text(0.887,-0.91,'.','FontSize',15)
text(0.13,0.125,'a')
text(-0.36,0.31,'b')
text(-0.45,-0.55,'c')
text(0.89,-0.20,'d')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -