Problem with equating for loop index to a variable.
이전 댓글 표시
I run the following code and it does not produce the expected results:
% code
clear all
FlowRate=0.6;
for ThermalImpCurve = 0.2:0.2:1.6
if FlowRate==ThermalImpCurve
ThermalImpCurve
break;
end
end
if the variable FlowRate is 0.6 or 1.4 the loop does not break.
댓글 수: 1
Stephen23
2016년 5월 13일
Welcome to the world of floating point number calculations!. This is such a common topic that the wiki has an explanation of it too:
There are hundreds of threads asking the same question (with the same answer)
and finally:
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!