Error "Function definitions are not permitted in this context" in matlab R2014a
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ali Saffar
le 7 Oct 2020
Réponse apportée : Walter Roberson
le 7 Oct 2020
I've tried to solve this system of equations: y_1 '=y_2 and y_2 '=-y_1 as follows:
clear all;
clc;
function dy = rigid(t,y)
dy = zeros(2,1);
dy(1) =y(2);
dy(2)=-y(1);
[T,Y] = ode113(@rigid,[0 12],[0 1 1]);
plot(T,Y(:,1),'-',T,Y(:,2),'-.')
but there's this error "Function definitions are not permitted in this context".
I was wondering if someone could help me about my problem.
Thanks in advance.
0 commentaires
Réponse acceptée
Plus de réponses (1)
Walter Roberson
le 7 Oct 2020
In R2014a, it was not permitted to define functions inside a script file.
Furthermore, functions defined inside a script file cannot be called from outside the script (not unless the script exports a copy of a handle to the function.)
You need to delete the lines
clear all;
clc;
0 commentaires
Voir également
Catégories
En savoir plus sur Entering Commands 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!