How to remove cells in cell matrix that are a certain value?

1 ビュー (過去 30 日間)
Dc215905
Dc215905 2021 年 6 月 18 日
編集済み: Rik 2021 年 6 月 19 日
Hello,
I have a 8x4 cell matrix that looks like:
1x761200 double 1x121400 double 1x299600 double 1x555000 double
1x761200 double 1x121400 double 1x299600 double 1x555000 double
1x761200 double 1x121400 double 1x299600 double 1x555000 double
1x761200 double 1x121400 double 1x299600 double 1x555000 double
-1 -1 -1 -1
-1 -1 -1 -1
1x761200 double 1x121400 double 1x299600 double 1x555000 double
1x761200 double 1x121400 double 1x299600 double 1x555000 double
I would like to find which rows contain '-1' and then remove those rows from the matrix.
Any suggestions?

採用された回答

Rik
Rik 2021 年 6 月 18 日
編集済み: Rik 2021 年 6 月 19 日
data(all(cellfun('prodofsize',data)==1),:)=[];
You might need to specify the dimension for the all function (writing of mobile, so no testing). You might also mean the any function instead of all.
Edit:
This does indeed require a modification:
L=all(cellfun('prodofsize',data)==1,2)
% ^^
data(L,:)=[]
  3 件のコメント
Dc215905
Dc215905 2021 年 6 月 19 日
Thank you! That works great!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by