|
|
! l2 X7 K% Q/ f0 Q2 ^
联用cellfun,arrayfun等函数
; F; P9 |( Q6 V% p* v4 Zc = cell(3,3);7 R* C; q3 \/ q2 ~( R+ h
c{1,1} = rand(1,2);
: W8 s7 x8 X; W0 @2 c8 P2 Qc{2,1} = rand(1,4);
) U4 I7 [% |3 G; g4 ^c{2,2} = rand(1,3);
F$ I& \4 O, m! tc{3,2} = rand(1,5);
7 `1 F# s$ B: t0 T3 Kc{3,3} = rand(1,6);
2 W, t8 I. K3 `. K; m1 \5 Xidx = find(~cellfun(@isempty,c));
; |/ V" D' n) E, v8 C5 t, J, g4 n5 i' bresult = arrayfun(@(ii) c{idx(ii)}, [1:1:numel(idx)],'UniformOutput', false)
5 U4 a5 D" t+ i2 W3 m0 g复制代码+ u* i4 @) E& N7 D# h+ i7 Z7 q$ q
+ q/ S7 U: b. L* d, m
result =$ D! Q' t; w0 K5 g
1×5 cell 数组5 ~( p8 i6 o8 Y/ P9 \/ `* Z+ A% E' z
{1×2 double} {1×4 double} {1×3 double} {1×5 double} {1×6 double} |
|