transforming some cells having 2-dimensional matrics to 3-dimensional matrics

1 view (last 30 days)
Hi all I have a variable named “A” which is in cell format as following:
A=cell(4,3);
A{:,:}=ones(16,5);
<16x5 double> <16x5 double> <16x5 double>
<16x5 double> <16x5 double> <16x5 double>
<16x5 double> <16x5 double> <16x5 double>
<16x5 double> <16x5 double> <16x5 double>
I want to transform each cell to a 3-dimensional matrix like following:
A{1,1}(:,:,1)=[
0.555 0.759 0.099 0.303 0.445
0.880 0.473 0.308 0.343 0.729
NaN NaN NaN NaN NaN
0.701 0.606 0.736 0.709 0.172 ];
A{1,1}(:,:,2)=[
0.594 0.355 0.023 0.213 0.473
0.847 0.118 0.272 0.589 0.905
0.853 0.018 0.373 NaN 0.932
0.093 0.136 0.420 0.996 0.509];
A{1,1}(:,:,3)=[
0.530 0.227 0.802 0.645 0.240
NaN 0.541 0.087 0.501 0.592
0.518 0.019 0.286 0.182 0.473
0.050 0.015 0.851 0.056 0.647];
A{1,1}(:,:,4)=[
0.345 0.174 0.131 0.557 0.829
0.940 0.329 0.878 0.289 0.081
0.309 NaN 0.166 0.766 0.082
0.521 0.275 0.820 0.245 0.244];
How can I do this, any help would appreciate

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 2 Feb 2014
Edited: Azzi Abdelmalek on 2 Feb 2014
A=cellfun(@(x) ones(16,5)*999999,A,'un',0) ;% Example
out=cellfun(@(x) reshape(x,4,1,[]),A,'un',0)
  2 Comments
som
som on 2 Feb 2014
tnks for your answer. i modified my question, please take a look one more time. best,
Azzi Abdelmalek
Azzi Abdelmalek on 2 Feb 2014
Edited: Azzi Abdelmalek on 2 Feb 2014
A=cellfun(@(x) ones(16,5)*999999,A,'un',0) ;% Example
out=cellfun(@(x) permute(reshape(x',5,4,[]),[2 1 3]),A,'un',0)

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!