|
4 s; E/ B7 G9 L/ P联用cellfun,arrayfun等函数& m7 v- h; K" l+ Z# r
c = cell(3,3);
! D* U& C* D3 Oc{1,1} = rand(1,2);1 Z s6 M, f8 X: ?& U
c{2,1} = rand(1,4);! G( _% E" ~5 j" B( e7 W! o
c{2,2} = rand(1,3);% G [+ C6 m: b+ g
c{3,2} = rand(1,5);
3 P: t H$ B% T9 ^( I$ c oc{3,3} = rand(1,6);: A. h% g" c, x2 l
idx = find(~cellfun(@isempty,c));$ s5 E& x- C* F/ Z
result = arrayfun(@(ii) c{idx(ii)}, [1:1:numel(idx)],'UniformOutput', false)0 _2 m7 m$ j# _7 ]& M- ^- n
复制代码3 t! K' Z0 X+ M' K
: O- e% X) N) i- t0 O2 f) h3 s5 tresult =
' H2 @3 Z- D/ s; y 1×5 cell 数组% P; \* x! Y$ O6 \' D7 @
{1×2 double} {1×4 double} {1×3 double} {1×5 double} {1×6 double} |
|