How can I delete a certain number of rows in a vector?
조회 수: 1 (최근 30일)
이전 댓글 표시
Dear all, I have a 2505*1 vector with only 1 and 0. The number 1 occurs 178 times. I want to delete the first 158 rows with an 1 and the last 20 rows and the rows with 0 should stay! How can I do that? Thank you in advance!
댓글 수: 0
채택된 답변
Image Analyst
2013년 4월 2일
rowsWithOnes = find(vector == 1)
vector(rowsWithOnes(1:158)) = []; % Delete first 158
vector(rowsWithOnes(end-19:end)) = []; % Delete last 20
댓글 수: 0
추가 답변 (1개)
Azzi Abdelmalek
2013년 4월 2일
편집: Azzi Abdelmalek
2013년 4월 2일
idx=find(A)
idx1=[idx(1:158) idx(end-19:end)]
A(idx1)=[];
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!