how to convert cell array to a matrix?
2 ビュー (過去 30 日間)
古いコメントを表示
I have a 5X4 matrix whose each element is a cell array. how to convert it to a simple matrix of elements.
5 件のコメント
回答 (1 件)
Jos (10584)
2018 年 7 月 30 日
A = {[1 2 3],[4 5],6 ; [11 12],13,[] ; 21, [22 23], [24 25]} % data
B = arrayfun(@(k) cat(2,A{k,:}),1:size(A,1),'un',0) % make row vectors
C = padcat(B{:}) % pad vectors with NaNs
My function PADCAT can be downloaded here: https://uk.mathworks.com/matlabcentral/fileexchange/22909-padcat-varargin
6 件のコメント
Jos (10584)
2018 年 8 月 1 日
This is all rather vague ... Can you show us some code, showing where you get stuck?
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!