Reshape row wise w/ different starting/ending elements number

后端 未结 3 1929
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 23:13

The problem is:

Product of known dimensions, 3, not divisible into total number of elements, 16.

this because i want to reshape a

3条回答
  •  抹茶落季
    2021-01-21 23:29

    You should add zeros in the beginnig. What I mean:

    vec      = [1:16]'
    nRow     = 3;
    nCol     = 6;
    zeroFill = nRow * nCol - length(vec);
    newVec   = [vec; zeros(zeroFill, 1)];
    mat      = reshape(newVec, [nRow nCol])
    

提交回复
热议问题