Brute force for finding optimal value
Afficher commentaires plus anciens
I have a function Say, f(x)=(1-0.5)*[(sin(x-0.25))/2]+0.5.
and x lie in range [-pi,pi], which need to be optimized such that the f(x) will be maximum. The final result f(x), after applying brute force, will be of order 1*10. How to incorporate it, using brute force?
Regards and thanks in anticipation.
2 commentaires
Torsten
le 28 Mar 2022
Your function does not depend on x.
Chetan Fadnis
le 28 Mar 2022
Réponse acceptée
Plus de réponses (1)
I don't understand. Your function has a single maximum at x=0.25+pi/2. Why are you talking about 10 x-values ?
Do you perhaps mean
f = @(x)(1-0.5)*sin(x-0.25)/2 + 0.5;
x = linspace(-pi,pi,10); % Choose 10 equidistant x-values
[imax,fmax] = max(f(x)); % find maximum and position under the 10 x-values
xmax = x(imax) % print out x position of maximum
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!