I need to find the number of periods since a stock price recorded an 14-day high. My proposed method was to use the following andpossibly subtract the index from the current row:
n = 14
[M,I] = movmax(high,[n-1 0],'omitnan');
However, I return - "error using movmax. Too many output arguments."
Can someone please assist in my methodology.

답변 (1개)

Walter Roberson
Walter Roberson 2021년 2월 21일

0 개 추천

There is no syntax for movmax() in which it returns a second output. It does not return the indices of the local maxima.

댓글 수: 4

david crowley
david crowley 2021년 2월 27일
So how do I find the index value for this problem?
Walter Roberson
Walter Roberson 2021년 2월 28일
Loop.
Raphael Willi
Raphael Willi 2021년 6월 10일
Loop how?
wid = 5;
N = 50;
signal = randi([-9, 9], 1, N)
signal = 1×50
-4 -9 -5 8 -6 -2 7 -3 6 -1 5 6 3 -5 -3 -3 -8 0 -8 7 -9 -3 6 0 4 2 -8 -9 3 -3
for K = 1 : N - wid + 1
[M(K), relI] = max(signal(K:K+wid-1));
I(K) = K + relI - 1;
end
M
M = 1×46
8 8 8 8 7 7 7 6 6 6 6 6 3 0 0 7 7 7 7 7 6 6 6 4 4 3 3 3 3 1
I
I = 1×46
4 4 4 4 7 7 7 9 9 12 12 12 13 18 18 20 20 20 20 20 23 23 23 25 25 29 29 29 29 34

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

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

태그

질문:

2021년 2월 21일

댓글:

2021년 6월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by