Know When to Use isequal()


isequal() is your best friend for Cody! It compares arrays perfectly without rounding errors — much safer than == for matrix outputs.
Christian Schröder
Christian Schröder on 12 Nov 2025
But keep in mind two things:
  1. Two NaNs are not usually considered equal. If you want this to be the case, use isequaln() instead.
  2. isequal(), like ==, may give counterintuitive results for floating-point numbers (isequal(0.1+0.2,0.3) is 0). Depending on your use case you may want isapprox() instead.