error in subtracting

10 ビュー (過去 30 日間)
kash
kash 2012 年 6 月 27 日
I have a code
if Sparse_Conc_Index>=1
---------
---------
---------
Class_Image = (Image_Path);
figure,imshow(Class_Image)
else
msgbox('Invalid Image ','ALERT')
end
if i do
F=1-Sparse_Conc_Index
i get
F = 5.1341e-011
please tell how to get F as zero
  2 件のコメント
Geoff
Geoff 2012 年 6 月 27 日
F = 0;
kash
kash 2012 年 6 月 27 日
Hello Geoff i cant understand

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2012 年 6 月 27 日
If F = 1 - Sparse_Conc_Index is positive, then Sparse_Conc_Index >= 1 is false, so your "if" should not be true.
Your problem then reduces down to why Sparse_Conc_Index is not at least 1, which is something we do not know as you do not show how you calculated Sparse_Conc_Index .

その他の回答 (1 件)

Andreas Goser
Andreas Goser 2012 年 6 月 27 日
The point is that 5.1341e-011 IS actually almost zero. It depends now on your application what is the best approach. Very often comparisions are made in a way that you don't compare with ==, but with a tolerance.
  1 件のコメント
kash
kash 2012 年 6 月 27 日
Andres depending on values of 5.1341e-011 i have to execute for example if this value is greater than 0 i want one operation else other operatiobn for ex
if F>=0
---------
---------
---------
else
-------------
------------
end
here wen i processed my if condition is not working only else part works,please help

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDynamic System Models についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by