Error "Function definitions are not permitted in this context" in matlab R2014a
7 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
More Answers (1)
Walter Roberson
on 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 Comments
See Also
Categories
Find more on Entering Commands 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!