How to extract data from a cell in a specific way ?

Suppose I have the following code
for n = 1:21
sz = [23,42000];
data = cell(sz);
for k = 1:12
x=foo( );
data{k}=x;
end
end
after its being executed I get a cell named data which has 12 1x69 arrays like this
1x69 double
1x69 double
1x69 double
1x69 double
1x69 double
1x69 double
1x69 double
1x69 double
1x69 double
1x69 double
1x69 double
1x69 double
Now I want to save this in an array outside of inside for and also add to this array the following 12 1x69 arrays for the end 20 itterations of the outside loop.
Eventually, I want to have 12x21=252 1x69 arrays in a single array 252x69.
I hope you guys understood what I am asking and I wish someone out there help me here, because I am clueless here...

2 件のコメント

sixwwwwww
sixwwwwww 2013 年 10 月 29 日
What is 'y' here?
Stamatis Samaras
Stamatis Samaras 2013 年 10 月 29 日
Ignore y , I'm removing it. Suppose foo is just providing values for cell

サインインしてコメントする。

 採用された回答

sixwwwwww
sixwwwwww 2013 年 10 月 29 日

1 投票

Dear Stamatis, here is code for converting cell array into a matrix:
for i = 1:12
data{i} = rand(1, 69); % create cell having 12 arrays of 1x69
end
a = reshape(cell2mat(data), [], 69); % storing the arrays in a matrix
Is it what you need?

4 件のコメント

Stamatis Samaras
Stamatis Samaras 2013 年 10 月 29 日
Sorry but this is not what I am looking for. For every itteration of outside for , inside for will place those values as I described above in cell {data} and I am looking for a way to extract those values for every itteration of outside for in a seperate array for later use.
sixwwwwww
sixwwwwww 2013 年 10 月 30 日
you can do it like this(if I understood correctly):
for n = 1:21
data1{n} = data; % data1 is a big cell array and its each cell has 12 1x69 arrays
sz = [23,42000];
data = cell(sz);
for k = 1:12
x=foo( );
data{k}=x;
end
end
Is it ok now?
Stamatis Samaras
Stamatis Samaras 2013 年 10 月 30 日
it does something interesting, I think its close to what I am looking for, I am going to work it out a bit and hopefully get the desired results. Thanks !
sixwwwwww
sixwwwwww 2013 年 10 月 30 日
You are welcome

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

質問済み:

2013 年 10 月 29 日

コメント済み:

2013 年 10 月 30 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by