-
Notifications
You must be signed in to change notification settings - Fork 5
/
csize.m
36 lines (31 loc) · 800 Bytes
/
csize.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
% CSIZE Returns dimension information for cell arrays.
% USAGE
% d=csize(b);
% [d,n]=csize(b);
% If b is a cell array then:
% d is the number of matrices in b
% m is a dx2 matrix of row and column dimensions
% or m and n are dx1 vectors
% If b is not a cell array
% d=[]; this can be used to test if b is a cell array
% (isempty(d) is true is b is not a cell array)
% m=size(b) or m=size(b,1) and n=size(b,2)
% Copyright (c) 1997-2000, Paul L. Fackler & Mario J. Miranda
% paul_fackler@ncsu.edu, miranda.4@osu.edu
function [d,m,n]=csize(b)
if iscell(b)
d=length(b);
m=zeros(d,2);
for i=1:d
m(i,:)=size(b{i});
end
else
d=[];
m=size(b);
end
if nargout==0
disp([(1:d)' m])
elseif nargout==3
n=m(:,2);
m=m(:,1);
end