How can I delete a certain number of rows in a vector?

1 vue (au cours des 30 derniers jours)
Thor
Thor le 2 Avr 2013
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!

Réponse acceptée

Image Analyst
Image Analyst le 2 Avr 2013
rowsWithOnes = find(vector == 1)
vector(rowsWithOnes(1:158)) = []; % Delete first 158
vector(rowsWithOnes(end-19:end)) = []; % Delete last 20

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 2 Avr 2013
Modifié(e) : Azzi Abdelmalek le 2 Avr 2013
idx=find(A)
idx1=[idx(1:158) idx(end-19:end)]
A(idx1)=[];

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by