Removing specific position in array

조회 수: 5 (최근 30일)
Lars Urban
Lars Urban 2022년 5월 3일
댓글: Lars Urban 2022년 5월 4일
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);

채택된 답변

David Hill
David Hill 2022년 5월 3일
time(time<starttime|time>endtime)=[];
  댓글 수: 3
David Hill
David Hill 2022년 5월 3일
high(time<starttime|time>endtime)=[];
time(time<starttime|time>endtime)=[];
Lars Urban
Lars Urban 2022년 5월 4일
Thank you! It works!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by