Complaint from a matlab user about Operation termination!!

11 ビュー (過去 30 日間)
dai zhengguo
dai zhengguo 2011 年 12 月 21 日
編集済み: Stephen23 2015 年 11 月 16 日
When I have run the matlab for a while, I terminated the program since I found a bug. Then nothing appeared in the workspace. I believe it is not a convenient way. I should check some data when I terminated at the same time. The only way is to trace some data into a file when the program begins. sigh

採用された回答

Walter Roberson
Walter Roberson 2011 年 12 月 21 日
Give the command
dbstop if error
before you run. Then, if you encounter an error message or press control-c, the program will stop at the current line and allow you to examine variables.
  6 件のコメント
Sean de Wolski
Sean de Wolski 2011 年 12 月 21 日
編集済み: Stephen23 2015 年 11 月 16 日
Coping your above 'aa' function and setting >> dbstop if error before I run it, when I hit crtl+c (Windows) as fast as I can:
a = 138949749 i = 138949751
dai zhengguo
dai zhengguo 2011 年 12 月 21 日
Thans a lot! dbstop if error is useful! Forgive my rude!

サインインしてコメントする。

その他の回答 (2 件)

Jan
Jan 2011 年 12 月 21 日
I agree the program you are using has a bad design. If it is a function and you have to terminate it by Ctrl-C, all performed work is lost.
I assume the programmer did not expect the user to kill the process. If a premature program termination can be expected, a GUI containing a "Terminate" button should offer a clean way to stop the execution. The program has to check the status of the button (or use any other method for message passing) and reply and useful data after cleaning up.
I do not understand, why you ask this here. Contacting the author of the program will be more helpful. Ask for an improved usability, especially some progress information and the possibility for a premature termination.
Be aware, that it is impossible for Matlab to perform all required and wished tasks automagically for you, because Ctrl-C is the brute way to stop all executions. Even a smart cleanup would be interupted!
  2 件のコメント
dai zhengguo
dai zhengguo 2011 年 12 月 21 日
write a function named aa in your matlab:
function a = aa
for i = 1:2147483647
a = i + 2;
end
Then type aa in the command widow. Use control+C to termined. You will find there is noting in the workspace of matlab.
However, if just type the funciton in command window, ctrl + c can save some variables in the workspace. I don't know what is the reason?
Malcolm Lidierth
Malcolm Lidierth 2011 年 12 月 21 日
Look in the MATLAB help under "scope"

サインインしてコメントする。


kumar verma
kumar verma 2015 年 11 月 16 日
編集済み: Walter Roberson 2015 年 11 月 16 日
wtf...when im typing sin(pi) im getting ans as 1.2246e-16 fine ..later i tried if x 0:pi/2:pi sin(x) i got ans 0 1 0......why ...wats the problem....should i write exam or not...plzz help me.... literally suffering a lot because of this problem...today 14:00 i should give my paper,... please reply asap...
thanks in advance
  1 件のコメント
Walter Roberson
Walter Roberson 2015 年 11 月 16 日
>> x = 0:pi/2:pi; sin(x)
ans =
0 1 1.22464679914735e-16
This is due to the fact that pi cannot be exactly represented in binary floating point numbers. However, you will find that sind(180) is 0 exactly because 180 is exactly representable in binary floating point and sind() checks for the multiples of 90 as a special case.
If you happened to work symbolically,
x = sym('pi'); sin(x)
then you would get 0 exactly because the symbolic toolbox is not limited to binary floating point numbers.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFunctions についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by