How can I delete some specific rows from a cell?

How can I delete som specific rows from a cell according to the matrix(see the pic). When the elementw of the Matrix are1 I must delete the same rows from the cell. Any ideas?
<<
<<
>>
>>

3 件のコメント

Adam
Adam 2016 年 9 月 23 日
What is the structure of your cell array? If it is a 2d cell array and you want to delete whole rows of it then it is trivial, but I'm guessing you mean you want to delete rows from the contents of each cell?
Thimiod Athan
Thimiod Athan 2016 年 9 月 24 日
編集済み: Thimiod Athan 2016 年 9 月 24 日
Hello Adam. I want to delete the 2 raws (with the red color) from the following cell(6X3)
Thimiod Athan
Thimiod Athan 2016 年 9 月 24 日
I think I find it Table(find(A==1),:)=[]. It was sooo easy...
Thanks for your help

回答 (2 件)

Image Analyst
Image Analyst 2016 年 9 月 23 日
編集済み: Image Analyst 2016 年 9 月 23 日

0 投票

What is "elementw" and "Matrix"? All we see are "Table" and "A".
If you have a cell array called ca, and you have a logical column vector "A", you can remove cells from ca where A is 1 or true like this:
caNew = ca(A==0); % Extract cells where A=0 (i.e. remove cells where A=1).
Or, equivalently
caNew = ca; % Initialize
caNew(A) = []; % Remove cells where A=1

3 件のコメント

Thimiod Athan
Thimiod Athan 2016 年 9 月 24 日
Hello,
Thank you for your help. I want to delete the 2 raws (with the red color) from the following cell(6X3)
Thimiod Athan
Thimiod Athan 2016 年 9 月 24 日
I think I find it Table(find(A==1),:)=[]. It was sooo easy...
Thanks for your help
Image Analyst
Image Analyst 2016 年 9 月 24 日
Even easier is to use logical indexing. No need for find():
Table(A==1,:)=[];
table is a built in function in MATLAB. Even though MATLAB is case sensitive, so table is different than table, it's a good idea not to use variable names that are the "same" as function names.
I could have told you this . . . if you'd been a little more careful about your question. For example you never mentioned the "Table" variable at all in your question. And you used the word "cell" in a non-MATLAB-ish way. Go here http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F for a very good discussion of cells in MATLAB.
Vignesh Murugavel
Vignesh Murugavel 2021 年 8 月 3 日

0 投票

Using Logical Indexing
Table(A==1,:)=[];

この質問は閉じられています。

質問済み:

2016 年 9 月 23 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by