How to delete every "n thru m" rows?
조회 수: 13 (최근 30일)
이전 댓글 표시
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
답변 (1개)
David Hill
2021년 4월 22일
I might not understand your question fully. What is the size of your matrix? (260x1)
yourMatrix(151:181,:)=[];%deletes rows in matrix
댓글 수: 2
David Hill
2021년 4월 22일
편집: David Hill
2021년 4월 22일
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))=[];
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!