How can I make function and find minimum
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Star Strider
el 3 de Dic. de 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 comentarios
Ver también
Categorías
Más información sobre Calculus en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!