I have a function statement that works in Octave but fails in Matlab
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Star Strider
2019년 12월 29일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Octave에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!