matlab老是显示input argument '' is undefined

学习 时间:2026-03-30 14:25:31 阅读:2969
matlab老是显示input argument '' is undefined我没法在matlab上面运行我写的这东西,因为总是显示Input argument "currentValues" is undefined.Error in ==> pendulumODE at 10theta = 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^2theta = currentValues(1);omega = currentValues(2);dTheta = omega;dOmega = -g*sin(theta)/L;derivs = [dTheta; dOmega];L = 0.248; % length in metersinitialValues = [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)')

最佳回答

故意的自行车

娇气的网络

2026-03-30 14:25:31

currentValues还没有定义,所以theta = currentValues(1);这样的语句不能执行。你的derivs是一个函数,调用它的时候应该把t,currentValues,L都传递给它才行。以上。专业路过的老狼

最新回答共有2条回答

  • 平常的花生
    回复
    2026-03-30 14:25:31

    currentValues还没有定义,所以theta = currentValues(1);这样的语句不能执行。你的derivs是一个函数,调用它的时候应该把t,currentValues,L都传递给它才行。以上。专业路过的老狼

上一篇 请补出“益习其声,又进出前后,终不敢搏.”句中省略的词语.

下一篇 上殸下召这个字怎么打?拼音是什么呀?我有个员工的名字是这辟字,她自己说只有康熙字典才有,麻烦呀