Question: I have two matrices x and y, both are results from different algorithms/routines that are supposed to calculate the same result. While I know that the isequal() would check if x and y are the same matrix, the entries in those matrices would not be exactly the same (i.e. some entries may be with 5% off in worst case scenario). In this scenario, what would be the best method of comparing them to see if they are close enough to be considered the same result? Thanks in advance for the advices.

Answer: 
Try this:

```
tf = abs((A-B)./B)<0.05

```

This will return a logical matrix which will be true for each element if the relative difference between A and B with respect to B is less than 5 percent.

If you want to ask if all of these are true (they all satisfy the above condition):

```
all(tf(:))

```
make use of 'isequal(a,b) where a and b are two matrices, if 1 it is true