Illegal use of reserved keyword "end".
150 次查看(过去 30 天)
显示 更早的评论
[T,Y] = ode45(@Bqfun1,[0 2],[1 1 -0.01]);
plot (T,Y(:,1),'b','linewidth',1)
function dy1 = Bqfun1(t,y)
dy1 = zeros(2,1);
dy1=[y(2);
y(3)
-3*y(3)-3*y(2)-y(1)-4*sin(t);
end
With the end in there
Error: File: Test4.m Line: 14 Column: 1
Illegal use of reserved keyword "end".
if I remove the end
Error: File: Test4.m Line: 17 Column: 1
All functions in a script must be closed with an 'end'.
Make up your mind MATLAB.
How do I put the end in for the function without the illegal use of reserved keyword "end."
0 个评论
采纳的回答
Cris LaPierre
2021-5-8
The problem is you forgot the closing bracket when creating dy1.
[T,Y] = ode45(@Bqfun1,[0 2],[1 1 -0.01]);
plot (T,Y(:,1),'b','linewidth',1)
function dy1 = Bqfun1(t,y)
dy1 = zeros(2,1);
dy1=[y(2)
y(3)
-3*y(3)-3*y(2)-y(1)-4*sin(t)];
end
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!