|
|
. O" I# Q, O! }) P7 e9 k联用cellfun,arrayfun等函数
! L5 A, c9 I3 g8 p9 {* J6 Y. T* ~c = cell(3,3);
l$ o. T2 `8 x. E5 Fc{1,1} = rand(1,2);
4 Z- D( U3 M* {c{2,1} = rand(1,4);0 M: c- G2 A& b. M6 p
c{2,2} = rand(1,3);
; v& Y: {8 N/ a# @. u' Sc{3,2} = rand(1,5);# n4 {" _( o0 I0 V! `; O: g8 G2 W& y" L
c{3,3} = rand(1,6);- U& C( k- P, Y0 B! T
idx = find(~cellfun(@isempty,c));1 U/ A. i- }* H! b
result = arrayfun(@(ii) c{idx(ii)}, [1:1:numel(idx)],'UniformOutput', false)0 l8 ?9 r4 J# e2 v
复制代码* L! X3 m5 ]. p0 F- ^" l- \
8 v/ O5 q: W; h# A; B0 Z
result =' R7 M* r% i. u2 d k3 j
1×5 cell 数组/ h" i9 L: t- C. @4 s( s$ |/ [
{1×2 double} {1×4 double} {1×3 double} {1×5 double} {1×6 double} |
|