Search code examples
matlabdoubleassert

Matlab - comparing multidimensional double/float arrays (isequal)


Assume I have two matrices A,B of values of type double.

What's the Matlab way of doing isequal(A,B) with some element-wise sensitivity (epsilon)?

E.g. all elements in A-B are smaller than some value (for instance 1e-10)


Solution

  • I think you want this:

    all( abs( A(:) - B(:) ) < tol )