0
angle_source=[-161.5:0.1:166.7];

angle1=[-161.2:2.6:161.2];

angle_index=zeros(1,length(angle1));

for i=1:length(angle1)

    angle_index(i)=find(angle_source==angle1(i));

end

It is not work when i is equal 4 in my computer, is it a MATLAB bug or my code?

DianK
  • 1
  • 1
  • You are doing equality comparison of floating-point values, which you should never do unless you know the numbers must be identical because the one was copied from the other. In this case they were not, they were computed by two different processes, yielding different rounding errors. The linked Q&A does a great job of explaining why this is a problem and how to work around it. – Cris Luengo Aug 27 '21 at 16:48

0 Answers0