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!