This question is closed. Reopen it to edit or answer.
How can I delete some specific rows from a cell?
1 view (last 30 days)
Show older comments
Thimiod Athan on 23 Sep 2016
Closed: MATLAB Answer Bot on 20 Aug 2021
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?
Image Analyst on 23 Sep 2016
Edited: Image Analyst on 23 Sep 2016
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).
caNew = ca; % Initialize
caNew(A) = ; % Remove cells where A=1
Image Analyst on 24 Sep 2016
Even easier is to use logical indexing. No need for find():
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 on 3 Aug 2021
Using Logical Indexing
Walter Roberson on 3 Aug 2021
That is what Image Analyst said nearly 5 years ago. https://www.mathworks.com/matlabcentral/answers/304242-how-can-i-delete-some-specific-rows-from-a-cell#comment_393354
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!