divideByZero warning does not show up when dividing by zero.

조회 수: 12 (최근 30일)
Adrien
Adrien 2011년 7월 29일
I am working with MATLAB 2011a, and I do not see the MATLAB:divideByZero warning appearing when I do divide by zero, though I set the divideByZero warning on with:
warning on MATLAB:divideByZero
I tried it with MATLAB 2009, and the warning appeared in this release. Unfortunately, I need to have it working on 2011a.
How can I get this warning to appear?
  댓글 수: 5
Paulo Silva
Paulo Silva 2011년 7월 29일
by default MATLAB doesn't give warning for divisions by zero
Adrien
Adrien 2011년 7월 29일
Thank you all for helping me. To answer your different questions:
- I tried it on a simple line of code as "1/0" and I got the warning in 2009a (once I activated the warning with "warning on MATLAB:divideByZero
"), but not in 2011a (even with the warning activated the same way).
- maybe MATLAB doesn't give warning by default for divisions by zero, but it should if it is activated. Still it doesn't in the 2011a release.
It's still quite weird to me.

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

채택된 답변

the cyclist
the cyclist 2011년 7월 29일
The following is in the Release Notes for R2009b. However, explicitly turning on the warning does not enable it for me, in R2011a. I don't see the warning on the screen, or using the lastwarn() function.
Divide By Zero and Log Of Zero Warnings Off By Default
MATLAB no longer displays Divide by zero and Log of zero warnings unless you explicitly enable them with the following commands:
warning on MATLAB:divideByZero
warning on MATLAB:log:LogOfZero
This only affects the display of the warning message on the screen; the warning status is still updated as usual.
  댓글 수: 3
Adrien
Adrien 2011년 7월 29일
In the Release Notes I mean.
Adrien
Adrien 2011년 7월 29일
My bad, there is no contradiction : these document just explain how to do it with the 2009 release, which works. I am going to look for an equivalent document for the 2011 release.

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

추가 답변 (2개)

the cyclist
the cyclist 2011년 7월 29일
I have R2010a, R2010b, and R2011a on my machine. None of them give a warning for 1/0. If 2009 gave the warning, looks like maybe the behavior changed at 2010a? Could scan the release notes.
  댓글 수: 1
Adrien
Adrien 2011년 7월 29일
I just tried it again, and there is a warning for a simple code as 1/0 with Matlab 2009a... but not with 2011a.

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


Walter Roberson
Walter Roberson 2011년 7월 29일
Enter the command
warning
It will show you the warnings that exist but which are not set to 'on'.

카테고리

Help CenterFile Exchange에서 Platform and License에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by