How to delete the row from cell array?
Mostrar comentarios más antiguos
I have a cell arraywhich has 10*6 matrix in it. How can I delete a row from the matrix? thanks in advance.
Respuesta aceptada
Más respuestas (3)
Azzi Abdelmalek
el 10 de Jul. de 2013
row=2
A(row,:)=[]
6 comentarios
siddhesh rane
el 10 de Jul. de 2013
Azzi Abdelmalek
el 10 de Jul. de 2013
row=2;
out=cellfun(@(x) x(setdiff(1:10,row),:),A,'un',0)
Shihao Wang
el 26 de Abr. de 2018
Thanks from 2018
Mehdi Maadir
el 9 de Jul. de 2021
Thanks from 2021
Tong Zhao
el 16 de Jun. de 2022
Thanks from 2022
Kris Hoffman
el 5 de Jul. de 2022
Thanks from 2026
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 comentarios
siddhesh rane
el 10 de Jul. de 2013
John
el 10 de Jul. de 2013
Ok I think I understand, you have a cell array that looks like the following:
A = {rand(5), 1}
A =
[5x5 double] [1]
You want to remove a row from the matrix in the first element of A. You can do the following:
A{1} = A{1}([1 2 4 5],1);
(this will remove the third row). Alternatively you can use Azzi Abdelmalek's method shown below:
A{1}(3,:) = []
I think this is what you are looking for.
siddhesh rane
el 10 de Jul. de 2013
siddhesh rane
el 10 de Jul. de 2013
0 votos
Categorías
Más información sobre Data Type Conversion en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!