How to convert multiple cell array matrix having different sizes (having different variable names) to single matrix with their variable names individually ?

조회 수: 1 (최근 30일)
Find the attachment of the image having the multiple cell arrays ? I need to convert those multiple cell array to matrix of the same size in a single matrix
Thanks

답변 (1개)

Walter Roberson
Walter Roberson 2016년 1월 5일
You only have a single variable in what you show. If you want to create a single array from it then
Bmat = cell2mat( cellfun(@int32, B, 'Uniform', 0) );
The cellfun() layer is to convert everything to the same datatype
  댓글 수: 2
Manoj
Manoj 2016년 9월 4일
I got the error given below
Error using cat
Dimensions of matrices being concatenated are not consistent.
Error in cell2mat (line 83)
m{n} = cat(1,c{:,n});
Walter Roberson
Walter Roberson 2016년 9월 4일
You only have a single variable in what you show. It cannot be converted to a single matrix because the number of rows varies from column to column. If you want to put all of the entries in a column together into one entry then you can use
newB = arrayfun(@(idx) vertcat(B{:,idx}), 1:size(B,2), 'Uniform', 0);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by