필터 지우기
필터 지우기

The mean function and decimal places

조회 수: 4 (최근 30일)
J.S.
J.S. 2018년 6월 15일
댓글: David Goodmanson 2018년 6월 16일
Below is a snippet of code that is acting unexpectedly:
maxmean= -inf;
stripemean=0;
while stripemean>=(10*maxmean)
%do something, including update stripemean and maxmean.
end
When the script ends and I type stripemean and maxmean into the command line, the results are
stripemean=0;
maxmean=0.01,
which should cause the while loop to keep running instead of ending as it did. Is there any way to adjust the number of decimal places allowed in the result of calling the mean function?
The vector upon which mean is acting to create stripemean is very long and contains mostly 0s (and some 1s).
  댓글 수: 3
Image Analyst
Image Analyst 2018년 6월 16일
What are you doing to change maxmean? If you're setting something to it, fine, but if you're multiplying it by something, keep in mind that (-inf * anything) is still -inf and so your while loop will never exit. So, what are you doing to update those values?
David Goodmanson
David Goodmanson 2018년 6월 16일
Hi JS,
Using the most recent values of stripemean and maxmean you have 0 < .1 and the while loop stops, as it should. Decimal places do not appear to be involved.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by