1
 tfinal = 10;
 dt_fine = 0.0000001;
 tvec_fine = [0:dt_fine:tfinal];
 find(tvec_fine==0.1)


ans =
Empty matrix: 1-by-0

Why does the above code not find the index where tvec_fine has the entry 0.1. It clearly has the entry based on the definition of tvec_fine.

1

1 Answer 1

0

This is because floating point has a narrow precision, and 0.1 could end up being 0.10000001 vs 0.1000000002 for example.

This is a very rough description just to give you an idea, as pointed in the comments more developed answers and solutions are already available on SO.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.