Error: Function definition are not supported in this context. Functions can only be created as local or nested functions in code files.
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Cris LaPierre
am 29 Mär. 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 Kommentare
Image Analyst
am 29 Mär. 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 Kommentare
Siehe auch
Kategorien
Mehr zu Startup and Shutdown 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!