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

1 回表示 (過去 30 日間)
som
som 2014 年 2 月 2 日
編集済み: Azzi Abdelmalek 2014 年 2 月 2 日
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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 2 日
編集済み: Azzi Abdelmalek 2014 年 2 月 2 日
A=cellfun(@(x) ones(16,5)*999999,A,'un',0) ;% Example
out=cellfun(@(x) reshape(x,4,1,[]),A,'un',0)
  2 件のコメント
som
som 2014 年 2 月 2 日
tnks for your answer. i modified my question, please take a look one more time. best,
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 2 月 2 日
編集済み: Azzi Abdelmalek 2014 年 2 月 2 日
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)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by