Minimalizing two variables back to back
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Walter Roberson
il 13 Giu 2022
https://www.mathworks.com/help/matlab/ref/fminsearch.html#bvadxhn-1-options
TolX would sound to be something you could use for that.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Graph and Network Algorithms in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!