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!