How to delete the row from cell array?

528 views (last 30 days)
siddhesh rane
siddhesh rane on 10 Jul 2013
Commented: Kris Hoffman on 5 Jul 2022
I have a cell arraywhich has 10*6 matrix in it. How can I delete a row from the matrix? thanks in advance.

Accepted Answer

Matt J
Matt J on 10 Jul 2013
Is this what you want:
>> A(1:2)={rand(10,6)}
A =
[10x6 double] [10x6 double]
>> row=2; A{1}(2,:)=[] %delete 1 row from 1 cell
A =
[9x6 double] [10x6 double]
  4 Comments
Matt J
Matt J on 28 Sep 2018
As Stephen says, you will have to use a loop, but you can also hide the loop with cellfun,
cellfun(@(c) c(1:800), yourCell, 'uni',0 )

Sign in to comment.

More Answers (3)

Azzi Abdelmalek
Azzi Abdelmalek on 10 Jul 2013
row=2
A(row,:)=[]
  6 Comments

Sign in to comment.


John
John on 10 Jul 2013
Edited: John on 10 Jul 2013
You can index out the rows like any standard array (the following code removes the second row):
x = {1 2 3; 4 5 6; 7 8 9}
x =
[1] [2] [3]
[4] [5] [6]
[7] [8] [9]
y = x([1 3],:)
y =
[1] [2] [3]
[7] [8] [9]
  3 Comments

Sign in to comment.


siddhesh rane
siddhesh rane on 10 Jul 2013
[A] [B] [C]
suppose i have 1*3 cell as shown above and A is a matrix of dimensions 3*3 and I want to delete second row of the A matrix. How should i do it?

Products

Community Treasure Hunt

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

Start Hunting!