|
|
( H5 a0 O1 b/ s- E- R i( H联用cellfun,arrayfun等函数7 P! J0 _# S8 G* p4 B1 N
c = cell(3,3);! n2 a7 k1 @3 x0 D/ N# a$ z6 M
c{1,1} = rand(1,2);
$ h! t$ C1 x+ L3 M6 ?& S w9 ?1 mc{2,1} = rand(1,4);0 G" g$ r& M' Z; w7 T. ~ e# W
c{2,2} = rand(1,3);
. `$ L) S- n8 P& [- X3 D- Sc{3,2} = rand(1,5);7 N5 { l0 X0 {
c{3,3} = rand(1,6);- d: H* r7 s; x4 O- d* {6 K
idx = find(~cellfun(@isempty,c));9 s# |' m/ l* x6 o
result = arrayfun(@(ii) c{idx(ii)}, [1:1:numel(idx)],'UniformOutput', false)% M- A5 g- s8 s
复制代码- v" t) Y7 y- N$ i9 I8 x5 F: d9 }
, a* v3 ]" k7 c9 y. J3 ]
result =
! W) X3 d. f3 z' u/ m l 1×5 cell 数组6 a0 {% B% ?+ Y5 H% `
{1×2 double} {1×4 double} {1×3 double} {1×5 double} {1×6 double} |
|