MATLAB 一元方程极值X=-9.8933+24.2405T-16.9282T^2+1.7470T^3X范围0

来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/28 18:05:06
MATLAB一元方程极值X=-9.8933+24.2405T-16.9282T^2+1.7470T^3X范围0MATLAB一元方程极值X=-9.8933+24.2405T-16.9282T^2+1.7

MATLAB 一元方程极值X=-9.8933+24.2405T-16.9282T^2+1.7470T^3X范围0
MATLAB 一元方程极值
X=-9.8933+24.2405T-16.9282T^2+1.7470T^3
X范围0

MATLAB 一元方程极值X=-9.8933+24.2405T-16.9282T^2+1.7470T^3X范围0
xm=0;
xM=6;
x0=1;
%%求最小值
ftouchby=inline('-9.8933+24.2405*T-16.9282*T.^2+1.7470*T.^3','T');
[Tmin,fmin]=fmincon(ftouchby,x0,[],[],[],[],xm,xM,''); %fmincon是求最小值
%%求最大值
ftouchby_1=inline('-1*(-9.8933+24.2405*T-16.9282*T.^2+1.7470*T.^3)','T'); %加一个负,求最小,就可以转化成:不加负时的最大
[Tmax,fmax]=fmincon(ftouchby_1,x0,[],[],[],[],xm,xM,'');
fmax=-fmax; %这里要转化回来
fmin,fmax
%以下验证
xx=xm:0.01:xM;
yy=ftouchby(xx);
plot(xx,yy)
min(yy)
max(yy)