How to resolve this

조회 수: 1 (최근 30일)
Shweta
Shweta 2024년 6월 7일
답변: Taylor 2024년 7월 2일
N1=function('N1')(t)
Error: Function definitions are not supported in this context. Functions can only be created as local or nested functions in code files.
  댓글 수: 2
Torsten
Torsten 2024년 6월 7일
What's the purpose of the line ?
Aquatris
Aquatris 2024년 6월 7일
편집: Aquatris 2024년 6월 7일
Matlab expects functions to be defined as:
function y = myFun(x)
%% YOUR FUNCTION GOES HERE %%
end
Also, within a script, they can only be defined in this way at the end of the script.

댓글을 달려면 로그인하십시오.

답변 (1개)

Taylor
Taylor 2024년 7월 2일
As stated, functions in MATLAB must be defined as:
function y = myFunc(x)
%% Do something
end
If the function is in a file by itself, the file name must be the function name. Terminating with an "end" statement is optional in this case. If the function is defined within a script, it may be placed anywhere as of R2024a.

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by