How to delete every "n thru m" rows?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a matrix which contians 27, 260 rows and one column. I need to delete every 151-181 rows of the data set. Is there a code with which I can do this? Essentially, instead of wanting to delete every "n" rows, I want to delete every "n thru m" rows. Thanks.
0 comentarios
Respuestas (1)
David Hill
el 22 de Abr. de 2021
I might not understand your question fully. What is the size of your matrix? (260x1)
yourMatrix(151:181,:)=[];%deletes rows in matrix
2 comentarios
David Hill
el 22 de Abr. de 2021
Editada: David Hill
el 22 de Abr. de 2021
Just add nan to end of matrix so you can reshape, and remove nan at end of operation.
yourMatrix(end+1:27512)=nan;
yourMatrix=reshape(yourMatrix,181,[]);
yourMatrix(151:181,:)=[];
yourMatrix=yourMatrix(:);
yourMatrix(isnan(yourMatrix))=[];
Ver también
Categorías
Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!