Complaint from a matlab user about Operation termination!!

조회 수: 10 (최근 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 CenterFile Exchange에서 Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by