finding the number of consecutive data

조회 수: 1 (최근 30일)
joseph Frank
joseph Frank 2013년 2월 1일
Hi,
I have a vector of 5000 obeservations containing nan values and prices. How can I tell if this vector contains 60 consecutive prices without any nan interruption?

채택된 답변

Thorsten
Thorsten 2013년 2월 1일
This should do the job:
obs1 = observations(1);
Ncons = 1;
for i = 2:numel(observations)
if observations(i) == obs1
Ncons = Ncons + 1;
if Ncons == 60, break; end
else
obs1 = observations(i);
Ncons = 1;
end
end
if Ncons == 60
disp('60 consecutive prices found.')
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by