How to find value of X when Y reaches maximum value

조회 수: 10 (최근 30일)
RAHUL YADAV
RAHUL YADAV 2020년 8월 18일
댓글: RAHUL YADAV 2020년 8월 20일
Hello,
I am new to MATLAB Simulink, I want output as the value of X when Y reaches maximum.
Y is a calculated value from an equation and is a function of X
  댓글 수: 4
Rik
Rik 2020년 8월 18일
I don't know much about Simulink, so I can't help you there. Once you have a function in Matlab itself you can use fminsearch. You want the maximum, so you would need to invert your function (inverted=@(varargin) -YourFunction(varargin{:});)
RAHUL YADAV
RAHUL YADAV 2020년 8월 19일
Thanks for the reply...
problem solved using Leonardo's approach

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

채택된 답변

maiaL
maiaL 2020년 8월 18일
Not sure what kind of output you want, but one way would be to get the derivative of your y(x) function. When it's "zero", it's at a maximum or minimum. I added quotes to "zero" because it's not going to be zero due to the time step of the solver. In the above example I'm getting the absolute of the derivative and when it's <= 0.01, I get the x value.
  댓글 수: 4
RAHUL YADAV
RAHUL YADAV 2020년 8월 20일
Thanks

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

추가 답변 (1개)

Sara Boznik
Sara Boznik 2020년 8월 18일

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by