Hi, I am Struggling to get the hidden error. I just need to put the specific markers at specific points on the chirp graph. The problem is that it gives me the error " 1×0 empty double row vector" at specific line AND when I wrote this line manually to get the indices, I got the answer without error. is that bug or am I missing something? please help. I attach my code you can run and you will get the error at point (301) i.e (x= .3). if you write Y(X==.3), you'll get the answer although it gave you error in the code.

In your code you are assuming that the ‘find’ operation will always find an index from X that will match one in xe. The trouble is that the decimal fraction values in these vectors cannot be exactly represented since your computer uses binary numbers. Presumably the two representations of .3 in the two vectors are slightly different, yielding an empty status for 'index'. To correct this you should allow a tiny tolerance for such differences rather than requiring exact equality.

Direct link to this comment

Added: The fact that Y(X==.3) gives an answer is not in contradiction with the above. Here are the actual computer values as expressed in format hex:

xe(4) -> 3fd3333333333334

X(301) -> 3fd3333333333333

.3 -> 3fd3333333333333

As you can see, X==.3 has an exact match, but X==xe(4) doesn’t. The latter is off in the least significant bit. And of course none of these is exactly 3/10 since that cannot be expressed exactly in binary.

Direct link to this comment

The ‘tol’ value should be smaller than the smallest difference that you want to elicit a false value and larger than the largest you tolerate for a true value. In your case these appear to be about .001 and 2*eps, respectively (eps = 2^(-52)), which leaves you a lot of room. I would choose tol = 10^(-12) in your case.