Finding the turning points

조회 수: 17 (최근 30일)
Reynand Joe
Reynand Joe 2023년 5월 1일
편집: Image Analyst 2023년 5월 2일
Hi i want to ask about something, i want to solve and locate the turning points (maximum and minimum point) of a graph using matlab gui but i dont know how to code it. The function is user defined and here is my code:
funcString = get(handles.edit1,'String');
funcHandle = str2func(['@(x)' funcString]);
x = linspace(10,-10,100);
y = funcHandle(x);
plot(handles.axes1,x,y);
  댓글 수: 3
Reynand Joe
Reynand Joe 2023년 5월 2일
yess
Image Analyst
Image Analyst 2023년 5월 2일

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

답변 (1개)

John D'Errico
John D'Errico 2023년 5월 1일
If all you will use are the 100 coarsely sampled points you are plotting, then min and max will do what you want. Look at the second arguments returned from min and max. You could also use findpeaks.
If you are willing to use the function itself, then you might use fminbnd. Note that fminbnd always searches fro a minimum. But you could then search for the minimum of -f(x), which would be the maximum of f.
  댓글 수: 2
Reynand Joe
Reynand Joe 2023년 5월 1일
Hi can you make me a code using this? I'm still at beginner level as matlab user and i dont have any idea how to code that
Image Analyst
Image Analyst 2023년 5월 2일
편집: Image Analyst 2023년 5월 2일
Did you look up min and max in the help? That would be the first step. Using your existing numerical array, "y", do this:
maxYValue = max(y)
minYValue = min(y)

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by