clc; clear all; close all; fx = @(x) -(0.4./sqrt(1 + x.^2) - sqrt(1+x.^2) .* (1- 0.4./(1 + x.^2))+x); [x0, f] =fminbnd(fx,0,2); % f利用负号求最小值 x = 0 :0.1: 2; y = feval(fx,x); %% ========maxvalue==== figure plot(x,-y,'b-','linewidth',2) hold on plot(x0,-f,'o','markersize',8,'linewidth',2,'markerFacecolor','g') xlabel('x') ylabel('y') text(x0, -f-0.02, 'maxvalue') %% ==============minvalue======= %% ========maxvalue==== figure(2) plot(x,y,'b-','linewidth',2) hold on plot(x0,f,'o','markersize',8,'linewidth',2,'markerFacecolor','g') xlabel('x') ylabel('y') text(x0, f+0.02, 'minvalue')