MATLAB练习例子十五(相位平面图)

返回

% sim2_3.m A = [0 1; -1 -1]; B = [0;1]; u = 1; dt = 0.05; tf = 20; x = [0 0]'; xx = []; i = 0; for t = 0:dt:tf i = i + 1; xx(:,i) = x; xt = x; for j=1:4 f = A*x + B*u; d(:,j) = f*dt; x = xt + d(:,j)*0.5; if j==3 x = xt + d(:,j); end end x = xt + (d(:,1) + d(:,2)*2 + d(:,3)*2 + d(:,4))/6; end plot(xx(1,:),xx(2,:)) grid on
% sim2_4.m A = [0 1; 0 0]; B = [0;1]; dt = 0.05; tf = 4; x = [2.5 0]'; l = 1; g = 9.8; a1 = g/l; xx = []; i = 0; for t = 0:dt:tf i = i + 1; xx(:,i) = x; xt = x; for j=1:4 u = -a1*sin(x(1)); f = A*x + B*u; d(:,j) = f*dt; x = xt + d(:,j)*0.5; if j==3 x = xt + d(:,j); end end x = xt + (d(:,1) + d(:,2)*2 + d(:,3)*2 + d(:,4))/6; end plot(xx(1,:),xx(2,:)) axis([-pi pi -10 10]) grid on
% sim2_5.m T = input('Tnter T: '); k1 = 1/T^2; k2 = 2/T; l0 = 0.8; l1 = 1.2; g = 9.8; A = [0 1 0 0; 0 0 0 0; 0 0 0 1; 0 0 -k1 -k2]; B = [0 0; 1 0; 0 0; 0 1]; dt = 0.01; tf = 10; x = [1 0 1 0]'; xx = []; i = 0; for t = 0:dt:tf i = i+1; xx(:,i) = x; xt = x; for j = 1:4 if x(1)*x(2) < 0 r = l0; else r = l1; end u = [(-g*sin(x(1)) - 2*x(4)*x(2))/x(3); k1*r]; f = A*x + B*u; d(:,j) = f*dt; x = xt + d(:,j)*0.5; if j == 3 x = xt + d(:,j); end end x = xt + (d(:,1) + d(:,2)*2 + d(:,3)*2 + d(:,4))/6; end t = 0:dt:tf; plot(t,xx(1,:),t,xx(3,:)) grid on





% sim2_6.m A = [0 1; 0 0]; B = [0; 1]; P = [-1+i -1-i]; %K = acker(A,B,P) K = place(A,B,P) 》 sim2_6 ??? 'acker' は未定義の関数、または変数です. エラー: ==> C:\mat\sim2_6.m 行番号: 5 ==>K = acker(A,B,P) 》 sim2_6 ??? 'place' は未定義の関数、または変数です. エラー: ==> C:\mat\sim2_6.m 行番号: 6 ==>K = place(A,B,P)
返回