Complaint from a matlab user about Operation termination!!

10 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

Walter Roberson
Walter Roberson il 21 Dic 2011
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 Commenti
Sean de Wolski
Sean de Wolski il 21 Dic 2011
Modificato: Stephen23 il 16 Nov 2015
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 il 21 Dic 2011
Thans a lot! dbstop if error is useful! Forgive my rude!

Accedi per commentare.

Più risposte (2)

Jan
Jan il 21 Dic 2011
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 Commenti
dai zhengguo
dai zhengguo il 21 Dic 2011
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?

Accedi per commentare.


kumar verma
kumar verma il 16 Nov 2015
Modificato: Walter Roberson il 16 Nov 2015
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 Commento
Walter Roberson
Walter Roberson il 16 Nov 2015
>> 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.

Accedi per commentare.

Categorie

Scopri di più su Functions in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by