Is there any way to stop a script launched with 'run' or 'source' from Matlab / GNU Octave? I mean different from Ctrl-C, say that a given condition (perhaps given by global variables) holds and a break signal is sent to it.
Example:
The script haltable.m is to be stopped when the environment variable takes a value higher than 0.5.
global environment
while (true)
environment = rand;
endwhile
It is launched with
global environment
run ('haltable.m')
Where (outside of haltable.m, of course) could it be specified that it must halt after the condition is met?
It is not possible to implement such a stop condition outside the script, matlab is single threaded and nothing outside is executed. Maybe a conditional breakpoint is what you are looking for.
You have to replace
5with the correct line number. This does not stop the script but halts it and switches to the debugger.