MATLAB: Error between each pixel for two matrices of equal size

errormatricesmatrix

Hi
I'm trying to find the error between to matrices of equal size. Let's say that my matrices are of size 4×4 :
A = [0 1 0 0; 1 1 0 0; 0 1 0 1; 0 1 1 0];
B = rand(4,4);
How would you find the error between each pixel of those matrices?

Best Answer

Wouldn't it just be
theError = A - B;
Caution: don't use error for the variable name since that is the name of a built-in MATLAB function.