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!