필터 지우기
필터 지우기

Peak-finding function doesn't work.

조회 수: 1 (최근 30일)
Jan
Jan 2011년 3월 30일
function [M] = peak(A)
for j=2:size(A,2)
if A(j,2)-A(j-1,2) >= 0 && A(j,2)-A(j+1,2) >= 0
M=[M,A(j,1)];
end
end
This is supposed to be a function that makes a vector M that contains all local peaks from a vector A. It doesn't do anything. Could anyone tell me what is wrong?
Greetings and thanks in advance

채택된 답변

Matt Fig
Matt Fig 2011년 3월 30일
What do you mean by, "Doesn't do anything?" Do you mean you get an error? I would imagine that the error is something about an undefined variable M. If you are going to do it this way, you should define M before the loop.
M = [];
  댓글 수: 2
Jan
Jan 2011년 3월 30일
I did that the first time, added it again and now it works. Very strange...
Matt Fig
Matt Fig 2011년 3월 30일
Does this mean that you accept the answer? Please indicate this by pushing the appropriate button.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by