how to convert cell array to a matrix?

조회 수: 2 (최근 30일)
Zara Khan
Zara Khan 2018년 7월 30일
댓글: Jos (10584) 2018년 8월 1일
I have a 5X4 matrix whose each element is a cell array. how to convert it to a simple matrix of elements.
  댓글 수: 5
Zara Khan
Zara Khan 2018년 7월 30일
I want to access this matrix as row by row
Zara Khan
Zara Khan 2018년 7월 31일
Bhowmik U: No its not working as we cant use cell for cell arrays.

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

답변 (1개)

Jos (10584)
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
  댓글 수: 6
Zara Khan
Zara Khan 2018년 7월 31일
yes that can be done using the above code. But what about when I am storing values from loops?
Jos (10584)
Jos (10584) 2018년 8월 1일
This is all rather vague ... Can you show us some code, showing where you get stuck?

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

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by