How to find value of X when Y reaches maximum value
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
RAHUL YADAV
am 18 Aug. 2020
Kommentiert: RAHUL YADAV
am 20 Aug. 2020
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/347391/image.png)
4 Kommentare
Rik
am 18 Aug. 2020
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{:});)
Akzeptierte Antwort
maiaL
am 18 Aug. 2020
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/347499/image.png)
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 Kommentare
maiaL
am 19 Aug. 2020
I would try using the max block: https://www.mathworks.com/help/simulink/slref/find-max-value-of-input.html
Weitere Antworten (1)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!