开发者

Matrix dimensions must agree?

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

Matrix dimensions must agree?


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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜