Taking a certain column from each cell with different size

Hi, I have some cells containing matrices with different size: for example a{1} : [1 2 3] a{2} : [1 2 3; 4 5 6; 6 7 8] a{3} : [1 2 3; 4 5 6; 7 8 9; 2 5 8; 4 5 6] Is there any "short way" that I can take second column of each matrix and merge them in a vector? number of cells and the size of matrices change with different input parameters.
thnx!
Chamran

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 7 月 8 日
編集済み: Azzi Abdelmalek 2016 年 7 月 8 日

1 投票

a{1} = [1 2 3]
a{2} = [1 2 3; 4 5 6; 6 7 8]
a{3} = [1 2 3; 4 5 6; 7 8 9; 2 5 8; 4 5 6]
b=cell2mat(a')
out=b(:,2)
%Or
out=cell2mat(cellfun(@(x) x(:,2),a','un',0))

その他の回答 (1 件)

chamran moradiashour
chamran moradiashour 2016 年 7 月 8 日

0 投票

WOW impressive! I tried a lot without inversing the "a"
Thankx habibi !

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by