[英]How to halt a script launched with 'run' in Matlab / GNU Octave?
Is there any way to stop a script launched with 'run' or 'source' from Matlab / GNU Octave? 有什么方法可以阻止从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.
我的意思是与Ctrl-C不同,它说给定条件(也许由全局变量给定)成立,并向它发送一个中断信号。
Example: 例:
The script haltable.m
is to be stopped when the environment
variable takes a value higher than 0.5. 当
environment
变量的值大于0.5时,将停止脚本haltable.m
。
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? 在哪里(当然在
haltable.m
之外)可以指定在满足条件后必须停止?
It is not possible to implement such a stop condition outside the script, matlab is single threaded and nothing outside is executed. 无法在脚本之外实现这种停止条件,matlab是单线程的,并且没有任何外部执行。 Maybe a conditional breakpoint is what you are looking for.
您可能正在寻找条件断点。
dbstop in haltable at 5 if (environment>.5)
You have to replace 5
with the correct line number. 您必须用正确的行号替换
5
。 This does not stop the script but halts it and switches to the debugger. 这不会停止脚本,但会停止脚本并切换到调试器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.