Transform matrix in vectors in a cell array

hi,
I have a cell of n matrix of size m * m. I want to turn it into m vectors of size n knowing that: example: transform
c = {[3 2;1 4] [6 8;7 5] [0 10;9 11]}
to
d = {[3 6 0] [2 8 10] [1 7 9] [4 5 11]}
without using (for end) because the size of my matrix is large
thank you in advance

回答 (2 件)

Matt J
Matt J 2013 年 12 月 24 日
編集済み: Matt J 2013 年 12 月 24 日

0 投票

There is no way you can do this without at least an implicit for-loop
C=cat(3,c{:});
D=permute(C,[2,3,1]);
d=reshape(num2cell(D,2),[],1); %uses for-loop inside num2cell.m
I don't understand why you wouldn't just work with the 3D numeric array C or D.

1 件のコメント

allnab
allnab 2013 年 12 月 25 日
thank you, it works correctly

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

Andrei Bobrov
Andrei Bobrov 2013 年 12 月 24 日

0 投票

num2cell(reshape([c{:}],4,[]),2)

カテゴリ

ヘルプ センター および File ExchangeMultidimensional Arrays についてさらに検索

質問済み:

2013 年 12 月 24 日

コメント済み:

2013 年 12 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by