1

Hi I keep getting the error:

    >> maxM = max(M);
    >> minM = min(M);
    >> Mnormalize = ((M-minM)./(maxM-minM) - 0.5 ) *2;
    ??? Error using ==> minus
    Matrix dimensions must agree.

M file looks like this enter image description here

G Gr
  • 6,030
  • 20
  • 91
  • 184

1 Answers1

2

This occurs if M is a two dimensional matrix.

If this is the case, then maxM and minM will actually be rows of M, and it fails due to the fact that you can't take for instance [1 2; 3 4] - [1 2].

If you want the minimum / maximum of the whole matrix, you probably want to do

maxM = max(M(:))
minM = min(M(:))

...and as PengOne said, / (instead of ./) should do just fine in this case.

Related question:

Community
  • 1
  • 1
aioobe
  • 413,195
  • 112
  • 811
  • 826