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!