Function definition not supported on cluster, but available in interactive mode
1 view (last 30 days)
Show older comments
When I try to run the following program
% Test program
for i=1:3600
waitawhile(1)
disp(i)
end
function waitawhile(time)
% wait time seconds
pause(time)
end
in Matlab (2020a) on a cluster in interactive mode (also with the -no-display option) and Matlab online it works perfectly, but when I submit it as a job on a cluster (srun matlab -nodisplay test.m) I get the following error
function waitawhile(time)
Error: Function definition not supported in this context. Create function in code file.
End
Error: Illigal use of reserved keyword 'end'
I am not sure why this error occurs and why Matlab should have a problem with a local function within a script. Is there a specific reason why this code does not work on the same cluster in interactive mode and not when submitted as a job?
4 Comments
Walter Roberson
on 29 Mar 2021
srun matlab -nodisplay test.m
That would, I think, attempt to execute test as a function and access a field named ".m"
Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!