www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@localpoly/max.m

    function [m,tps]= max(p);
% POLYNOM/MAX  find maximum of polynomial if it exists

%  Copyright 2000-2004 The MathWorks, Inc. and Ford Global Technologies, Inc.



d1=diff(p);
tps= code(p,roots(d1));

d2=diff(d1);
d2vals= eval(d2,tps);

% get rid of complex roots, minima and points of inflexion
tol= 1e-8;

tps = tps(abs(tps-real(tps))<tol & abs(d2vals-real(d2vals))<tol & real(d2vals)<0);
m = eval(p,tps);