Hi I keep getting the error:
>> maxM =开发者_JAVA技巧 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
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:
- How to normalize / denormalize a vector to range [-1;1]
精彩评论