I issue following command in the interactive matlab console:
>> foo = [1 inf];
>> dbstop if naninf
>> foo
I now get weird behaviour: matlab seems to to break into two different files, but doesn't actually stop execution. This is pretty slow because the editor switches between those two files repeatedly, Ctrl+C doesn't do anything. Output is:
481 end
20 if ~isfloat(value)
20 if ~isfloat(value)
399 if numel(var) > numelLimit
20 if ~isfloat(value)
20 if ~isfloat(value)
399 if numel(var) > numelLimit
20 if ~isfloat(value)
20 if ~isfloat(value)
399 if numel(var) > numelLimit
...
...
it then finally stops with a debug prompt, with a really long (recursive) stack like:
dbstack
In codetools/private/dataviewerhelper>upconvertIntegralType at 20
In codetools/private/dataviewerhelper at 9
In workspacefunc>createComplexScalar at 271
> In workspacefunc>num2complex at 241
In workspacefunc>getShortValueObjectJ at 230
In workspacefunc>getShortValueObjectsJ at 349
In workspacefunc at 21
In codetools/private/dataviewerhelper>upconvertIntegralType at 20
In codetools/private/dataviewerhelper at 9
In workspacefunc>createComplexScalar at 271
In workspacefunc>num2complex at 241
In workspacefunc>getShortValueObjectJ at 230
In workspacefunc>getShortValueObjectsJ at 349
In workspacefunc at 21
In workspacefunc>getStatObjectsJ at 399
In workspacefunc at 27
In codetools/private/dataviewerhelper>upconvertIntegralType at 20
In codetools/private/dataviewerhelper at 9
In workspacefunc>createComplexScalar at 271
In workspacefunc>num2complex at 241
In workspacefunc>getShortValueObjectJ at 230
In workspacefunc>getShortValueObjectsJ at 349
In workspacefunc at 21
In codetools/private/dataviewerhelper>upconvertIntegralType at 20
In codetools/private/dataviewerhelper at 9
In workspacefunc>createComplexScalar at 271
In workspacefunc>num2complex at 241
In workspacefunc>getShortValueObjectJ at 230
In workspacefunc>getShortValueObjectsJ at 349
In workspacefunc at 21
In workspacefunc>getStatObjectsJ at 399
In workspacefunc at 27
...
...
In my real program I'm trying to debug I get the same but even worse so that sometimes I hit the recursion limit error and abort, sometimes matlab simply completely crashes. I would really like to be able to use dbstop if naninf
, but this makes it pretty much impossible and this makes me sad. Any advice?
Using Matlab 2009b 64 bit on linux.
Thanks!
Edit:
I just tried it on matlab 2007b 32 bit Linux:
>> foo = [1 inf]
foo =
1 Inf
>> dbstop if naninf
>> foo
foo =
1 Inf
>> foo = [1 inf]
foo =
1 Inf
>>
>> t = foo(2)
t =
Inf
So here dbstop if naninf does't seem to do anything when deliberately assigning inf to a variable. The docs say:
bstop if naninf or dbstop if infnan stops execution when any MATLAB program file you subsequently run produces an infinite value (Inf) or a value that is not a number (NaN) as a result of an operator, function call, or scalar assignment, putting MATLAB in debug mode, paused immediately after the line where Inf or NaN was encountered.
Shouldn't this hit even when I deliberately assign a inf to a variable (as in above t = foo(2) or s = inf) or what is meant by "scalar assignment"?