필터 지우기
필터 지우기

Finding Min and Max of a sinusoidal function

조회 수: 28 (최근 30일)
Articat
Articat 2019년 4월 3일
답변: Star Strider 2019년 4월 3일
Hi,
So I have the following code and I want to find the min and max of the function. I tried using 'xmin' and 'ymin' but it outputs all of the values instead of the ones I am looking for. Based off the plot I should be getting 4 xmin and 4ymin points as well as 3xmax and 3ymax points.
Anything would help! Thanks.
  댓글 수: 1
Walter Roberson
Walter Roberson 2019년 4월 3일
You define
fv = 1:n;
What is it that you expect
minx = min(fv,fv(:,1))
to return?

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

채택된 답변

Star Strider
Star Strider 2019년 4월 3일
I note that you’re using the code change I suggested, even though you did not Accept my previous Answer.
If you have R2017a or later, you can use the islocalmax (link) and the related islocalmin (linked to in that page) functions:
Try this instead:
min_y = find(islocalmin(TL));
max_y = find(islocalmax(TL));
The correspoinding ‘f’ values are ‘fv(min_y)’ and ‘fv(max_y)’.
If you don’t have those functions and do have the Signal Processing Toolbox, use the findpeaks function instead.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2019년 4월 3일
편집: Walter Roberson 2019년 4월 3일
findpeaks(x,y) for the maxima, and findpeaks(x,-y) for the minima.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by