matlab用函数图像怎么求一个函数的最大值

2024-11-27 10:39:19
推荐回答(1个)
回答1:

图都画出来了,还怕找不到极值点:-) 最简单的办法是直接从图上找,精度绝对够了

clear all;
clc;close all;
h= ezplot('-19.313+295.27*6.09*42.1*x/1000-165.44*(6.09*42.1*x/1000)^2+40.874*(6.09*42.1*x/1000)^3-3.8445*(6.09*42.1*x/1000)^4-y*0.074/6.09',[1,100,1,20000]);
hold on;
y=get(h,'YData'); %获得y数据
x=get(h,'XData'); %获得x数据
[peak_y,i]=findpeaks(y);%找极值
peak_x=x(i);    % 极值点 x
plot(peak_x,peak_y,'r*');
grid on;

peak_y =


  1.4397e+004

peak_x =


    8.1566