Minimalizing two variables back to back

4 ビュー (過去 30 日間)
Ben Smith
Ben Smith 2022 年 6 月 13 日
コメント済み: Walter Roberson 2022 年 6 月 13 日
So i have two variables, P1 and P2 that i am trying to optimise by minimalising a function.
clear
V1 = fminsearch(@SepScoreMatch,17); %function to optimise a value of V1
V2 = fminsearch(@SepScoreMatchP2,0.1); %function to optimise a value of V2 using the value of V1.
However, when i try to run this i get the error 'Unrecognized function or variable 'V1'.'
Is there a way i can write this for it to work? Possibly putting V1 = fm..... as the first line of V2?
Also is there a 'better' was i could do this. For instance is there a minimalising function that optimises one parameter then the other?
The function for V1 is basically matching the x values of the max points (the graph looks like a 'u' in shape so has two peaks) of a curve in a graph and V2 is basically the width which i do by
score = 1:length(ygraph2);
for i = 1:length(y2)
diffsquared = (y1(i,1)-y2(i,1))^2;
score(i) = diffsquared;
end
MeanScore = mean(score);
Sadly i cant just fmin both variables at the same time as graph 2 is always much wider than graph 1. So it tries to minimalise Meanscore by making the tips of the graph wider a which leads to an overeall smaller value of
TotalScore = PeakDiff+MeanScore
but less accurate actual values. This is why i am trying to optimise one then the other.
  3 件のコメント
Ben Smith
Ben Smith 2022 年 6 月 13 日
Is there a way of doing
options = optimoptions(@fminunc,'StepTolerance',0.01);
But for fminsearch? because i cant see anything like that in the possible fields of optimset?
Walter Roberson
Walter Roberson 2022 年 6 月 13 日
https://www.mathworks.com/help/matlab/ref/fminsearch.html#bvadxhn-1-options
TolX would sound to be something you could use for that.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by