Error: Function definition are not supported in this context. Functions can only be created as local or nested functions in code files.
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
function [mvnx] = load_mvnx('New-Session-002');
↑
Error: Function definition are not supported in this context. Functions can only be created as local or nested functions in code files.
How do I fix this error in "load_mvnx.m" code?
0 comentarios
Respuestas (2)
Cris LaPierre
el 29 de Mzo. de 2023
You'd have to share your .m file for us to say for certain, but the error message you are getting suggests you are trying to define a function in a location where it is not allowed.
0 comentarios
Image Analyst
el 29 de Mzo. de 2023
You have your m-file something like this
function [mvnx] = load_mvnx('New-Session-002');
% code
end % of load_mvnx
% Now script is defined below the function definition.
clc
output = load_mvnx
when it should be like this:
clc;
filename = 'New-Session-002';
[mvnx] = load_mvnx(filename) % Call the function
% Define the function at the bottom of the m-file, below the script part.
function [mvnx] = load_mvnx(filename)
% code
end % of load_mvnx. The "end" is required if you're defining a function in a script m-file.
The script should be called something like test.m, not load_mvnx.m.
0 comentarios
Ver también
Categorías
Más información sobre Startup and Shutdown en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!