I have a function statement that works in Octave but fails in Matlab
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Star Strider
am 29 Dez. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Octave 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!