MATLAB練習(xí)例子十五(相位平面圖)

返回

% 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' は未定義の関數(shù)、または変數(shù)です. エラー: ==> C:\mat\sim2_6.m 行番號: 5 ==>K = acker(A,B,P) 》 sim2_6 ??? 'place' は未定義の関數(shù)、または変數(shù)です. エラー: ==> C:\mat\sim2_6.m 行番號: 6 ==>K = place(A,B,P)
返回
德兴市| 昆山市| 峨眉山市| 平山县| 沁源县| 清远市| 原平市| 溧水县| 福鼎市| 南昌县| 河池市| 泰州市| 桑日县| 章丘市| 开平市| 张家川| 册亨县| 呼伦贝尔市| 镇沅| 清流县| 福泉市| 新源县| 天镇县| 纳雍县| 子洲县| 石阡县| 奉新县| 奎屯市| 合肥市| 民勤县| 通化县| 阿图什市| 全州县| 宣化县| 万载县| 汉川市| 新巴尔虎右旗| 湖州市| 五原县| 英德市| 麻江县|