Effacer les filtres
Effacer les filtres

Illegal use of reserved keyword "end".

82 vues (au cours des 30 derniers jours)
David Scidmore
David Scidmore le 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."

Réponse acceptée

Cris LaPierre
Cris LaPierre le 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

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by