problem with making a very simple matrix
3 ビュー (過去 30 日間)
古いコメントを表示
Hi I am using 32 bit Matlab 2009b on a macintosh computer with OS 10.6.8. I am running in to a problem in Matlab that I cant figure out the reason. Here is my very simple code: c(:,1)=0.30:0.05:0.95; c(:,2)=0.35:0.05:1.00; find(c(:,2)==0.4)
and here is the answer in the command line: ans =
Empty matrix: 0-by-1
supposedly the c(2,2) should be 0.4 and indeed it looks like it is. But the find command cannot find it. on the other hand it does find 0.3 0.7 etc. I multiplied the c by 1000 and looks like some of the values in it will be 300, 500 etc and some other values like 0.4 will be 400.000. I am not sure what is going on here. Is this a known bug? is there a fix for it?
Thanks, Maryam
0 件のコメント
採用された回答
Arturo Moncada-Torres
2011 年 9 月 1 日
The problem is that you are trying to compare floating point numbers. This is clearly explained in the MATLAB FAQ. Also check this recent previous thread which addresses the same problem.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!