在Matlab中合并2D矩阵以形成3D矩阵 [英] Combine 2D matrices to form 3D one in Matlab

查看:147
本文介绍了在Matlab中合并2D矩阵以形成3D矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个20x2 double数组ABC.我想将它们组合到一个3d数组D中,以便D(:,:,1)将返回AD(:,:,2)将返回BD(:,:,3)将返回C.

I have 3 20x2 double arrays A, B and C. I want to combine them in one 3d array D so that D(:,:,1) will return A, D(:,:,2) will return B and D(:,:,3) will return C.

推荐答案

使用 cat 沿第三维连接是一种优雅的方法-

Using cat to concatenate along the third dimension might be the elegant way -

D = cat(3,A,B,C)

此处,第一个输入参数3指定要执行级联的维度.

Here, the first input argument 3 specifies the dimension along which the concatenation is to be performed.

这篇关于在Matlab中合并2D矩阵以形成3D矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆