How to find the size of a cell array
조회 수: 592 (최근 30일)
이전 댓글 표시
I have a cell array (raw from xlsread) that contains multiple data types. Is there a way to measure the size (length and width) of this cell array or convert it to a matrix so I can use the size function?
댓글 수: 0
채택된 답변
Sean de Wolski
2011년 6월 21일
A = cell(20,11);
size(A)
ans =
20 11
works for me... ? Or do you want the size of the contents of each cell?
cellsz = cellfun(@size,A,'uni',false);
Addendum per comment:
I still am not getting what you want.
clear A
>> A{1} = single(ones(4));
>> A{2} = uint8(toeplitz(1:10));
>> A{3} = 'Hello World'
A =
[4x4 single] [10x10 uint8] 'Hello World'
>> size(A)
ans =
1 3
>> cellsz = cellfun(@size,A,'uni',false);
>> cellsz{:}
ans =
4 4
ans =
10 10
ans =
1 11
댓글 수: 5
Labeeb Ahmed
2012년 8월 6일
One more doubt pls..
I have a cell array that may be empty,having one element or more than one element. how can i make decision accorind to size of cell array ?? ie. size(s) = 0 1 or size(s) = 1 1 or size(s) = 3 1 . I only need the information that how many rows are there Thnks in advance
Sean de Wolski
2012년 8월 6일
@Labeeb, this really should be a new question. The answer is to use isempty.
doc isempty
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!