Parse error at "t"

2 次查看(过去 30 天)
Belle Dionido
Belle Dionido 2021-12-4
编辑: KSSV 2022-3-6
I am trying to type:
[(d^2)y/d(t^2)] + 3.6(dy/dt) + 3.24y = -10(e^(-1.8t))
but it is saying parse error at 't' on line 5
function dydt = order2(~,y)
dydt = zeros(size(y));
a = 3.6; %coefficient for y; term
b = 3.24; %coefficient for y term
r = -10*e-1.8t; %forcing function
dydt(1) = y(2);
dydt(2) = r -a*y(2) - b*y(1);

采纳的回答

Dave B
Dave B 2021-12-4
When you multiply in MATLAB you need a * symbol
r = -10*e-1.8t;
should be
r = -10*e-1.8*t;
  1 个评论
Steven Lord
Steven Lord 2021-12-4
You will also need to define a variable named t in your function by replacing the ~ in the function signature on the first line with t.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品


版本

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by