필터 지우기
필터 지우기

Find the minimum of a function on a plot and where it occurs on the x-axis

조회 수: 2 (최근 30일)
Eileen
Eileen 2022년 2월 10일
댓글: David Hill 2022년 2월 10일
So I'm new to MatLab and I have a function that's plotting temperature vs time in hours and I need to find the minimum temperature and which hour it occurs on the x-axis. Is there any way to find this using a function and only use one line of Matlab? Thank you
  댓글 수: 1
David Hill
David Hill 2022년 2월 10일
I would recommend fitting your data to a function (use fit() function), then finding the minium temperature would be easy. Why do you care about how many lines of code? If you just want the minimum of your discrete data then:
[Min,idx]=min(temp);
Time=t(idx);

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

답변 (2개)

John D'Errico
John D'Errico 2022년 2월 10일
편집: John D'Errico 2022년 2월 10일
You have a function of one variable. Perhaps you should spend some time reading about tools like fminbnd, or even fminsearch. Either of those tools would solve your probem.
In the docs for those functions, you will see examples of how they can be used.

Star Strider
Star Strider 2022년 2월 10일
If the plot is of data and not of funciton evaluations, the min function could be useful.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by