Removing specific position in array

5 次查看(过去 30 天)
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)=[];

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by