我正在尝试使用数据创建一个多维数组。 我有一个17x10x1024的空单元阵列:
C=cell(length(data(1,:)),10,1024);
% length(data(1,:) = 17
然后我计算(在一个while循环(17次))矢量1024x1:
value = data(:,i) + randn(size(t))*noise_out;
现在我想将这些向量的值分配给数组,其方式如下:
'Name of Signal' [] [] [] [] [] [] [] [] []
'in1' [1024x1 double] [] [] [] [] [] [] [] []
'out1' [1024x1 double] [] [] [] [] [] [] [] []
'in2' [1024x1 double] [] [] [] [] [] [] [] []
'out2' [1024x1 double] [] [] [] [] [] [] [] []
'in3' [1024x1 double] [] [] [] [] [] [] [] []
'out3' [1024x1 double] [] [] [] [] [] [] [] []
'in4' [1024x1 double] [] [] [] [] [] [] [] []
'out4' [1024x1 double] [] [] [] [] [] [] [] []
'in5' [1024x1 double] [] [] [] [] [] [] [] []
'out5' [1024x1 double] [] [] [] [] [] [] [] []
'in6' [1024x1 double] [] [] [] [] [] [] [] []
'out6' [1024x1 double] [] [] [] [] [] [] [] []
'in7' [1024x1 double] [] [] [] [] [] [] [] []
'out7' [1024x1 double] [] [] [] [] [] [] [] []
'in8' [1024x1 double] [] [] [] [] [] [] [] []
'out8' [1024x1 double] [] [] [] [] [] [] [] []
我使用以下内容:
C(i,2,:) = {value};
% i is the number of loop from 2 to 17
,但问题是我确实得到一个字符串'[1024x1 double]'而不是矢量的实际值。
有什么想法吗?
答案 0 :(得分:2)
你想要得到的东西对我来说似乎并不合理,因为你在单元格中有很多单个值,你宁愿使用向量。
我建议三个选择:
C=cell(length(data(1,:)),10);
C(i,2) = value;
它为您提供一个单元格矩阵,其中您的名字在一列中,而单元格则在其他列中包含您的信号向量
但实际上我建议不要在单元格数组中存储名称和信号。因此,如果您需要带有信号的3D矩阵,请将名称分开并创建:
C = zeros(length(data(1,:)),10,1024);
C(i,2,:) = value;
或考虑使用结构;
signal(1).name = 'in1'
signal(1).values = value
signal(2).name = 'out1'
signal(2).values = value2
这些都只是想法,我没有尝试过,因为你没有提供足够的信息。