Illegal use of reserved keyword "end".

158 Ansichten (letzte 30 Tage)
David Scidmore
David Scidmore am 8 Mai 2021
Beantwortet: Cris LaPierre am 8 Mai 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."

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 8 Mai 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

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by