|
: U: R7 D& S$ A' o# [- x联用cellfun,arrayfun等函数
( k, {4 S) S3 U( j% zc = cell(3,3);
5 h% s$ e& l5 N& Z* M7 k/ R" \) Yc{1,1} = rand(1,2);7 i3 x7 N- p. p6 S" ] \
c{2,1} = rand(1,4);# d& ^; H, e; m. r
c{2,2} = rand(1,3);1 ?2 w0 W0 `8 T1 K" Z4 j
c{3,2} = rand(1,5);
( p! }5 c a; t; j \( @c{3,3} = rand(1,6);
4 B' u) n }* K& R# `3 jidx = find(~cellfun(@isempty,c));
& x& I l2 o! E2 F) f3 S% Z% kresult = arrayfun(@(ii) c{idx(ii)}, [1:1:numel(idx)],'UniformOutput', false)
2 L. x# ], R) S: s" k& w复制代码9 E! D' x- k( w% \1 ]; E& u" @' E
* u3 s/ ]- n# Z6 d! ~% W% |' yresult =
/ Y$ ^! L+ Z8 s4 b9 k2 v0 Q0 K 1×5 cell 数组# D5 r% m" u9 ^6 [3 H: s5 N2 V# \6 p+ }
{1×2 double} {1×4 double} {1×3 double} {1×5 double} {1×6 double} |
|