# セル配列のゼロ要素削除

64 views (last 30 days)
yuya4490 on 26 Mar 2024
Commented: yuya4490 on 23 May 2024
こんにちは。

%データの例
%要素がtable型　１つの要素は空のTable
Var1=(1:10)';
Var2=rand(10,1);
T1=table(Var1,Var2)
T2=table([],[])
CA={T1,T2,T1}'
ここでT2のような空のTableの要素だけを削除する方法はありますでしょうか。
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Accepted Answer

Shunichi Kusano on 26 Mar 2024
Edited: Shunichi Kusano on 26 Mar 2024

Var1=(1:10)';
Var2=rand(10,1);
T1=table(Var1,Var2);
T2=table([],[]);
CA={T1,T2,T1}'
CA = 3x1 cell array
{10x2 table} { 0x2 table} {10x2 table}
is_empty = cellfun(@isempty,CA)
is_empty = 3x1 logical array
0 1 0
CA(is_empty) = [] % 削除
CA = 2x1 cell array
{10x2 table} {10x2 table}
##### 1 CommentShow -1 older commentsHide -1 older comments
yuya4490 on 23 May 2024

Sign in to comment.

### Categories

Find more on table in Help Center and File Exchange

R2024a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!