Borrar filtros
Borrar filtros

How to resolve this

3 visualizaciones (últimos 30 días)
Shweta
Shweta el 7 de Jun. de 2024
Respondida: Taylor el 2 de Jul. de 2024
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 comentarios
Torsten
Torsten el 7 de Jun. de 2024
What's the purpose of the line ?
Aquatris
Aquatris el 7 de Jun. de 2024
Editada: Aquatris el 7 de Jun. de 2024
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.

Iniciar sesión para comentar.

Respuestas (1)

Taylor
Taylor el 2 de Jul. de 2024
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.

Categorías

Más información sobre Dialog Boxes en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by