2017-02-25 140 views
-2

我该如何创建这个多维3D单元阵列? https://www.mathworks.com/help/matlab/math/ch_data_struct6.gif enter image description here多维3D单元阵列

+0

由于单元阵列可以保存任何其它Matlab的类型(包括单元格数组),您可以将投入数据填入其中。 – Rotem

+0

那么,我实际上需要创建一个3D单元格数组,其中每个单元格有5个变量(不同类型),我可以稍后使用for循环为其赋值。 我遇到了这种结构的语法问题。 – Anyaa

+0

@Rotem ........ – Anyaa

回答

0

您链接的图像没有描绘3D单元格阵列,而是3D结构数组。例如,包含第一个“患者”的信息的结构可以通过以下方式构造:

patient(1,1,2).name = 'Al Smith'; 
patient(1,1,2).billing = 504.70; 
patient(1,1,2).test = [80 80 80; 153 153 154; 181 190 183]; 
0

可以帮助你与第一患者:

%Allocate 3D empty cell array (cell array dimension is 2x2x2). 
patient = cell(2, 2, 2); 

%Set details of first patient. 
patient{1, 1, 2}.name = 'Al Smith'; %Set name field (string). 
patient{1, 1, 2}.billing = 504.70; %Set billing field (double). 
patient{1, 1, 2}.test = [80, 80, 80; 153, 153, 154; 181, 190, 182]; %Set test field (3x3 matrix). 

%Continue with next patient: 
patient{1, 2, 2}.name = 'Dora Jones'; 
%... 
%...