How can I make function and find minimum
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
E = problem_energy;
V = problem_volume;
[p,~,mu]=polyfit[V,E,6);
Now I have coefficient in p 1x6 How can I make polynomial equation with this and find minimum? I want to use fminsearch
0 commentaires
Réponses (1)
Star Strider
le 3 Déc 2014
Use the polyder function to get the first derivative (and, if you want to be efficient, the second derivative as well), then use the roots function and basic calculus to find the minimum.
Example:
p = polyfit([-1:0.01:2], cos(-1:0.01:2),6); % Polynomial Coefficients
d1p = polyder(p); % First Derivative
d2p = polyder(d1p); % Second Derivative
ips = roots(d1p); % Inflection Points
xtr = polyval(d2p, ips); % Evaluate ‘d2p’ at ‘ips’
minpts = ips((xtr > 0) & (imag(xtr)==0)); % Find Minima
x = linspace(min(ips)-5,max(ips)+5);
ep = polyval(p,x);
figure(1)
plot(x, ep, '-r')
hold on
plot(minpts, polyval(p,minpts), 'bp')
hold off
grid
0 commentaires
Voir également
Catégories
En savoir plus sur Calculus dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!