0

I'm trying to create a multidimensional array with data. I have a 17x10x1024 empty cell array:

C=cell(length(data(1,:)),10,1024);

 % length(data(1,:) = 17

Then I am calculating (in a while loop (17 times) ) vectors which are 1024x1:

value = data(:,i) + randn(size(t))*noise_out;

Now I want to assign the values of this vectors to the array, in such a way that:

'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]    []    []    []    []    []    []    []    []

I use the following:

C(i,2,:) = {value};

% i is the number of loop from 2 to 17

,but the problem is that I literally get a string '[1024x1 double]' instead the real values of the vectors.

Any ideas?

4

1 回答 1

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

这些都只是想法,我还没有尝试过,因为你没有提供足够的信息。

于 2013-10-27T12:46:24.690 回答