time series with time lags

조회 수: 4 (최근 30일)
YH
YH 2020년 9월 22일
답변: Ameer Hamza 2020년 9월 22일
Hallo every one,
I have an array called sl(24000*1) which represents daily sea level measurements.
I have another array idx(34*1) represents the indexes of the annual maximum of a river discharg near the above mentioned gauge station
now I have to make a new time series of sea levels corresponding to the annual maximum of the river discharge time series
with time lags (-3 to +3) days, that means for each idx, i should find the coressponding value in sl with a range of -3 to +3 days.
for i = 1: size(idx,1)
out = sl(idx(i)-3:idx(i)+3);
end
this gives me only one value with its time lags
can some one tell me where exactly I am doing wrong?
Thanks in Advance!
  댓글 수: 1
Khaled Hamed
Khaled Hamed 2020년 9월 22일
out(i,:) = sl(idx(i)-3:idx(i)+3)';

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

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 9월 22일
This will create a single vector with all the required values
idx_all = arrayfun(@(x) {x-3:x+3}, idx);
out = sl([idx_all{:}])

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by