如何在Matlab中停止正在运行的脚本 [英] how to stop a running script in Matlab

查看:2403
本文介绍了如何在Matlab中停止正在运行的脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我在Matlab中编写了运行时间长的脚本

I write a long running script in Matlab, e.g.

tic;
d = rand(5000);
[a,b,c] = svd(d);
toc;

它似乎永远运行.因为我在编辑器窗口中按F5键.因此,我无法按C-Break在Matlab控制台中停止.

It seems running forever. Becasue I press F5 in the editor window. So I cannot press C-Break to stop in the Matlab console.

我只想知道如何停止脚本.我目前正在使用任务管理器杀死Matlab,这真是愚蠢.

I just want to know how to stop the script. I am current use Task Manager to kill Matlab, which is really silly.

谢谢.

推荐答案

Matlab帮助说: 对于长时间运行的M文件,或调用长时间运行的内置文件或MEX文件,Ctrl + C并不总是有效地停止执行.通常,这发生在Microsoft Windows平台而不是UNIX [1]平台上.如果遇到此问题,可以通过在M文件中包含例如drawow,pause或getframe函数(例如在大循环中)来帮助MATLAB中断执行.请注意,如果使用-nodesktop选项启动MATLAB,则Ctrl + C的响应速度可能会变慢.

Matlab help says this- For M-files that run a long time, or that call built-ins or MEX-files that run a long time, Ctrl+C does not always effectively stop execution. Typically, this happens on Microsoft Windows platforms rather than UNIX[1] platforms. If you experience this problem, you can help MATLAB break execution by including a drawnow, pause, or getframe function in your M-file, for example, within a large loop. Note that Ctrl+C might be less responsive if you started MATLAB with the -nodesktop option.

因此,我认为不存在任何选择.许多复杂的Matlab函数都会发生这种情况.我们要么必须等待,要么不使用它们.

So I don't think any option exist. This happens with many matlab functions that are complex. Either we have to wait or don't use them!.

这篇关于如何在Matlab中停止正在运行的脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆