Illegal use of reserved keyword "end".
164 views (last 30 days)
Show older comments
David Scidmore
on 8 May 2021
Answered: Cris LaPierre
on 8 May 2021
[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 Comments
Accepted Answer
Cris LaPierre
on 8 May 2021
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 Comments
More Answers (0)
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!