How to create a 2D array from the first column of a 3D array?
1 次查看(过去 30 天)
显示 更早的评论
I have a 3D array of size(N,N,sz). I want to create a 2D array of size(N,sz) where the columns of the 2D array correspond to the first column from every sz-th array from the 3D array. I have tried the following but there is a "Subscripted assignment dimension mismatch" as an error:
2Darray=permute(3Darray,[1 3 2]);
2Darray=reshape(2Darray, [], size(3Darray,2),1);
for m=1:1:sz
2Darray(:,m)=3Darray(:,1,m)
end
0 个评论
采纳的回答
Guillaume
2017-1-13
2Darray = squeeze(3DArray(:, 1, :));
%or
2Darray = permute(3DArray(:, 1, :), [1 3 2]);
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!