[英]Combine 2D matrices to form 3D one in Matlab
我有3個20x2 double
數組A
, B
和C
我想將它們組合到一個3d數組D
以便D(:,:,1)
將返回A
, D(:,:,2)
將返回B
而D(:,:,3)
將返回C
像這樣?
A = 1*ones(20,2);
B = 2*ones(20,2);
C = 3*ones(20,2);
D = zeros(20,2,3); % Preallocate the D Matrix
D(:,:,1) = A;
D(:,:,2) = B;
D(:,:,3) = C;
D(1,1,1) % prints 1
D(1,1,2) % prints 2
D(1,1,3) % prints 3
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.