Effacer les filtres
Effacer les filtres

Removing specific position in array

5 vues (au cours des 30 derniers jours)
Lars Urban
Lars Urban le 3 Mai 2022
Commenté : Lars Urban le 4 Mai 2022
I want to remove the element that are outside the starttime and endtime. Like for example it could be for the first 20 and last 5 entrys. I tried with the function nonzeros and it works for the time array, because the time array only have elements > 0, but not for the high. But I dont know how to remove it on a other way. Below is the Code that I use.
for j = 1:length(high)
if time(j)>= starttime && time(j)<=endtime
t(j) = time(j);
high(j) = high(j);
else
high(j) = [];
end
end
time = nonzeros(time);

Réponse acceptée

David Hill
David Hill le 3 Mai 2022
time(time<starttime|time>endtime)=[];
  3 commentaires
David Hill
David Hill le 3 Mai 2022
high(time<starttime|time>endtime)=[];
time(time<starttime|time>endtime)=[];
Lars Urban
Lars Urban le 4 Mai 2022
Thank you! It works!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical 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