运行脚本停止在中间 [英] running script stop in the middle

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

问题描述

我有一个脚本进行一些计算,并将一些不可见的图保存到Linux服务器上for循环内的图像文件中.

I have a script doing some computation and save some invisible plots into image files inside a for-loop on a linux server.

当我运行脚本时,它通常卡在中间的某个位置.我不确定它到底在哪里停止,但是我可以通过打印输出知道它在for循环的哪个迭代中停止.如果我从停止它的迭代中重新运行它,它可能会继续运行到该位置.所以在我看来没有错误.

When I run the script, it usually get stuck in somewhere in the middle. I am not sure where exactly it stopped, but I can know at which iteration of the for-loop it stops by print-out. if I rerun it from the iteration where it stopped, it could continue to run past that place. So it seems to me there is no bug.

我只是想知道如何确定停在哪一行?

I just wonder how I can identify at which line it stops?

什么可能是问题的原因,以及如何从头到尾运行整个脚本?

what might be the cause of the problem and how I can run the whole script from the beginning till the end?

谢谢!

更新:

我使用dbstop

dbstop if error  
dbstop if warning  
run path2script

跑步仍然被卡住,并且没有给出任何有关原因的消息.

The running still gets stuck somewhre and no message is given regarding why.

推荐答案

这是找出正在发生的事情的一种方法:

Here is one way to find out what is going on:

  1. 打开dbstop if error
  2. 一旦您的代码确实卡住了,请按CTRL + C,这将使您检查情况并查看发生了什么情况

  1. Turn on dbstop if error
  2. Once your code is really stuck, hit CTRL+C, this will allow you to inspect the situation and see what is going on

如果看不够,请选择引起错误的行,然后按f9键.

If looking is not enough: select the line where the error was induced and hit f9.

如果仍然没有找到错误,请放置一个条件断点,该条件断点仅在达到错误发生期间/之后的条件之后才触发.如果多次达到此目标,您将以某种方式陷入循环.

If you still didn't find the error, place a conditional breakpoint that only triggers after you reach the conditons during which/after the error occurs. If this is reached multiple times you are stuck in a loop somehow.

旁注:如果不确定自己是否处于循环状态,则最新版本的Matlab都有一个自动格式化按钮,请使用它!

Sidenote: If you are not sure whether you are in a loop, recent versions of Matlab have an autoformatting button, use it!

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

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