필터 지우기
필터 지우기

how to use dbstop if naninf

조회 수: 9 (최근 30일)
Habib
Habib 2013년 5월 10일
댓글: John Hatrick 2018년 3월 16일
I want to ask matlab to stop anywhere in my functions, a variable becomes nan or inf. I defined a function buggy(x) (which is a matlab example in help page of dbstop).
function z = buggy(x)
n = length(x);
u=8/0
z = (1:n)./x;
I just added one line ( u=8/0) to see how dbstop if naninf works. when I ran, matlab started violating. The response is in the following code:
>> dbstop if naninf
>> buggy(3)
u =
Inf
NaN/Inf breakpoint hit for buggy on line 3.
Stopping at next line.
3 u=8/0
4 z = (1:n)./x;
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
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
20 if ~isfloat(value)
20 if ~isfloat(value)
399 if numel(var) > numelLimit
20 if ~isfloat(value)
...and continuing...
and matlab stays in debugging mode and if I try doing something in matlab, it freezez.
Am I using dbstop in a wrong syntax or a wrong place?
I want matlab to stop and any inf/nan that that I have produced in my own codes. apparently it stops in its own built-in matlab files as well.
  댓글 수: 1
John Hatrick
John Hatrick 2018년 3월 16일
I have this problem too!
setting 'dbstop if naninf' finds tons of inf statements in MATLAB scripts I'm not using such as 'fsolve.m' and 'trustnleq.m.'
I want to find if a variable goes NaN; I don't care if the phrase 'inf' shows up in a script...
Respectfully, John

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2013년 5월 10일
You're definitely not doing anything wrong. It works fine for me. What version of MATLAB is this? Maybe try again after restarting MATLAB? Or maybe try reinstalling.
  댓글 수: 1
Habib
Habib 2013년 5월 11일
Matlab 2009a. I have to upgrade to the 2012b in a few days. Thanks buddy for trying the code.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by