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 日
Does it have to be inside Simulink, or is it also possible to move this problem to Matlab itself?
RAHUL YADAV
RAHUL YADAV 2020 年 8 月 18 日
Rik, thanks for the reply
This model is in Simulink so it would be better if the answer is related to same..
But still I can use user defined function to use MATLAB code having X and Y axes as input...
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 日

0 投票

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 月 19 日
This helps...
Thanks
RAHUL YADAV
RAHUL YADAV 2020 年 8 月 19 日
1) I got the zero crossing of y=f(x) (maxima)...
2) And after using the switch I am getting a spike at which the condition is approx zero
3)At last, what can I do get the output of value of X... like in this case ''displays 0.13.. something''
maiaL
maiaL 2020 年 8 月 19 日
RAHUL YADAV
RAHUL YADAV 2020 年 8 月 20 日
Thanks

サインインしてコメントする。

その他の回答 (1 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink についてさらに検索

製品

タグ

質問済み:

2020 年 8 月 18 日

コメント済み:

2020 年 8 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by