matlab老是显示input argument '' is undefined
来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/07/03 07:20:14
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)')
currentValues还没有定义,所以theta = currentValues(1);这样的语句不能执行.
你的derivs是一个函数,调用它的时候应该把t,currentValues,L都传递给它才行.
以上.
专业路过的老狼
你的derivs是一个函数,调用它的时候应该把t,currentValues,L都传递给它才行.
以上.
专业路过的老狼
matlab老是显示input argument '' is undefined
matlab?Input argument "a" is undefined.
MATLAB:Input argument "x" is undefined
MATLAB:Input argument "x" is undefined.
matlab问题?Input argument 'X' is undefined.
matlab ? Input argument "t" is undefined.
matlab Input argument "x" is undefined.
matlab运行结果Input argument "A" is undefined.
matlab错误:Input argument "x" is undefined.Error in ==> overla
在用matlab解微分方程时提示如下信息:Input argument "y" is undefined.Error i
MATLAB 程序错误?Input argument "f" is undefined.Error in ==> jun
matlab程序运行出现?Input argument "x" is undefined.Error in ==> my