I have a function statement that works in Octave but fails in Matlab
4 views (last 30 days)
Show older comments
my code in Octave is
for j= 1:12
I(j)= Io +j*DI;
j
x
[x ,fval] = fsolve(@(x) f(x,I(j)), x0, options);
y1(j)= x(1)
y2(j)= x(2)
x0 = x
endfor
plotyy (I , y1 , I , y2 )
function [y] = f( x , I )function [y] = f( x , I )
MAtlab says
Error: File: CurrentagainstT.m Line: 20 Column: 1
Function definition not supported in this context. Create functions in code file.
What am I supposed to do
3 Comments
Answers (1)
Star Strider
on 29 Dec 2019
In most instances, only anonymous functions can occur in a script file in MATLAB.
- Starting in R2016b, another option for storing functions is to include them at the end of a script file.
so it is possible, with some restrictions. See the cited (and related) documentation for details.
0 Comments
See Also
Categories
Find more on Octave 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!