把三维矩阵的所有页竖着拼接起来,不能用reshape
a = rand(2,3,4);
b = [];
for i=1:4
b = cat(1,b,a(:,:,i));
end
% b = reshape(a,8,3); % 效果不对
a=
val(:,:,1) =
0.8147 0.1270 0.6324
0.9058 0.9134 0.0975
val(:,:,2) =
0.2785 0.9575 0.1576
0.5469 0.9649 0.9706
val(:,:,3) =
0.9572 0.8003 0.4218
0.4854 0.1419 0.9157
val(:,:,4) =
0.7922 0.6557 0.8491
0.9595 0.0357 0.9340
b =
0.8147 0.1270 0.6324
0.9058 0.9134 0.0975
0.2785 0.9575 0.1576
0.5469 0.9649 0.9706
0.9572 0.8003 0.4218
0.4854 0.1419 0.9157
0.7922 0.6557 0.8491
0.9595 0.0357 0.9340
而reshape(a,8,3)得到的:
0.8147 0.9575 0.4218
0.9058 0.9649 0.9157
0.1270 0.1576 0.7922
0.9134 0.9706 0.9595
0.6324 0.9572 0.6557
0.0975 0.4854 0.0357
0.2785 0.8003 0.8491
0.5469 0.1419 0.9340
横着拼接每一页的二维矩阵
a = rand(3,2,4);
b = reshape(a,3,8); % reshape维度写(行维,列维*页维)
>> a = rand(3,2,4)
a(:,:,1) =
0.9172 0.7537
0.2858 0.3804
0.7572 0.5678
a(:,:,2) =
0.0759 0.7792
0.0540 0.9340
0.5308 0.1299
a(:,:,3) =
0.5688 0.3371
0.4694 0.1622
0.0119 0.7943
a(:,:,4) =
0.3112 0.6020
0.5285