matlab老是显示input argument '' is undefined我没法在matlab上面运行我写的这东西,因为总是显示Input argument "currentValues" is undefined.Error in ==> pendulumODE at 10theta = currentValues(1);function derivs = pendulumODE(t,curr
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/28 08:14:30
matlab老是显示input argument '' is undefined我没法在matlab上面运行我写的这东西,因为总是显示Input argument "currentValues" is undefined.Error in ==> pendulumODE at 10theta = currentValues(1);function derivs = pendulumODE(t,curr
matlab老是显示input argument '' is undefined
我没法在matlab上面运行我写的这东西,因为总是显示
Input argument "currentValues" is undefined.
Error in ==> pendulumODE at 10
theta = currentValues(1);
function derivs = pendulumODE(t,currentValues,L);
% Nonlinear Pendulum:(odefun)
%
% dTheta/dt = omega
% dOmega/dt = -gsin(theta)/L
%
% Our job is to set:dervis = [dTheta/dt; dOmega/dt]
% using the currentValues = [theta; omega].
g = 9.8; % m/s^2
theta = currentValues(1);
omega = currentValues(2);
dTheta = omega;
dOmega = -g*sin(theta)/L;
derivs = [dTheta; dOmega];
L = 0.248; % length in meters
initialValues = [0.5,0]; % theta(t=0) and omega(t=0)
timeSpan = [0 10]; % seconds
[t,theta] = ode45(@(t,v) pendulumODE(t,v,L),timeSpan,initialValues);
plot(t,theta)
xlabel('time (seconds)');
ylabel('\theta (blue),\omega (green)')
matlab老是显示input argument '' is undefined我没法在matlab上面运行我写的这东西,因为总是显示Input argument "currentValues" is undefined.Error in ==> pendulumODE at 10theta = currentValues(1);function derivs = pendulumODE(t,curr
currentValues还没有定义,所以theta = currentValues(1);这样的语句不能执行.
你的derivs是一个函数,调用它的时候应该把t,currentValues,L都传递给它才行.
以上.
专业路过的老狼