作者bofongwang (是你的宝贝)
站内MATLAB
标题[问题] 请教那里出了问题
时间Wed Sep 12 10:10:13 2012
第一个档案
% file pend1a.m
%
function xdot = pend1a(t,x)
u = 0.1;
xdot(1) = x(3);
xdot(2) = x(4);
xdot(3) = -x(2) + 1*u;
xdot(4) = 21.6*x(2) - 2*u;
end
第二个档案
% file simul1a.m
%
t0 = 0;
tf = 0.8;
x0 = [0;0;0;0];
[t,x] = ode45('pend1a',t0,tf,x0); % ode45 numerically solves
ord.diff.equations (ode)
subplot(2,1,1)
plot(t,x(:,1))
title('Inverted Pendulum Simulation 1a')
xlabel('t [s]'), ylabel('z(t) [m]'), grid
subplot(2,1,2)
plot(t,x(:,2))
xlabel('t [s]'), ylabel('theta(t) [rad]'), grid
已经有上网查过,好像是因为这是要调变的程式,无法直接执行。但还是不懂如何执行,
能请版友指导一下我这新手如何运行这个程式,感谢
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.116.1.134