How can I make function and find minimum
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Star Strider
2014 年 12 月 3 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Calculus についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!