How to find out all the possible values of x&y that make a function maximum?

5 ビュー (過去 30 日間)
IvanC
IvanC 2022 年 10 月 26 日
回答済み: Shubham 2024 年 3 月 20 日
Say there is a function, f(x, y) = sin(3x) + sin(2y), how can I find out all the possible values(In a certain range) of x&y that maximize the function using fminsearch function?
And the results need to be displayed in the command lines.
I am a beginner at Matlab, I've tried using fminsearch function but it could only gave out one solution. Someone help me please.
  1 件のコメント
Torsten
Torsten 2022 年 10 月 26 日
Do you know when sin(3*x) becomes 1 ?
Do you know when sin(2*y) becomes 1 ?
All pairs of these x-y-values are solutions.

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

回答 (1 件)

Shubham
Shubham 2024 年 3 月 20 日
Hi IvanC,
To find the maximum of a function using fminsearch in MATLAB, you actually need to search for the minimum of the negative of that function because fminsearch is designed to find the minimum value. However, finding all possible values within a certain range that maximize the function is a bit more complex because fminsearch typically converges to a local minimum (or in our case, a local maximum when we consider the negative of the function) based on the initial guess provided.
Given the periodic nature of your function, f(x, y) = sin(3x) + sin(2y), there will be multiple local maxima within any range that spans multiple periods of the sine function. fminsearch won't inherently find all these maxima; it will only find one, depending on the initial guess.
To systematically find multiple local maxima, you would need to run fminsearch multiple times with different initial guesses spread across your range of interest. However, this approach doesn't guarantee finding all maxima, especially in more complex landscapes, without a more sophisticated global optimization strategy. MATLAB's Global Optimization Toolbox offers functions like GlobalSearch and MultiStart that are more suited for this purpose.

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by