cell conversion to mat

2 ビュー (過去 30 日間)
Murugan C
Murugan C 2020 年 5 月 12 日
回答済み: Fangjun Jiang 2020 年 5 月 12 日
Hi,
I have cell arrray and i want to convert cell to mat.
a = {[111,116];[389,396];146;173;[156,161];166;180;175;167;176;168;[158,163]}
I used cell2mat function but i got error
out = cell2mat(a);
Error using cat
Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 83)
m{n} = cat(1,c{:,n});
How can I get out as below
out = {111;116;389;396;146;173;156;161;166;180;175;167;176;168;158;163};
Is it possible to do?
Thanks in Advance!

採用された回答

Fangjun Jiang
Fangjun Jiang 2020 年 5 月 12 日
b=cellfun(@(x) x(:), a, 'UniformOutput', false)
out=cell2mat(b)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by