问题描述:
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 "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)')
问题解答:
我来补答展开全文阅读