创建一个3D矩阵 [英] Create a 3D matrix

查看:139
本文介绍了创建一个3D矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在MATLAB中定义3D矩阵?

How can I define a 3D matrix in MATLAB?

例如尺寸为(8 x 4 x 20)的矩阵,还是将第3维添加到现有的2D矩阵中?

For example a matrix of size (8 x 4 x 20) or add a 3rd dimension to an existing 2D matrix?

推荐答案

创建3D矩阵

A = zeros(20, 10, 3);   %# Creates a 20x10x3 matrix

将第三维添加到矩阵

B = zeros(4,4);  
C = zeros(size(B,1), size(B,2), 4);  %# New matrix with B's size, and 3rd dimension of size 4
C(:,:,1) = B;                        %# Copy the content of B into C's first set of values

零点只是制作新矩阵的一种方法.对于3D矩阵,另一个可能是A(1:20,1:10,1:3) = 0.要确认矩阵的大小,可以运行:size(A)给出20 10 3.

zeros is just one way of making a new matrix. Another could be A(1:20,1:10,1:3) = 0 for a 3D matrix. To confirm the size of your matrices you can run: size(A) which gives 20 10 3.

矩阵的维数没有明确的限制.

There is no explicit bound on the number of dimensions a matrix may have.

这篇关于创建一个3D矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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