x=0:0.001:2; y=humps(x); plot(x,y); 如何求其最大值,需要matlab的程序?

来源:学生作业帮助网 编辑:六六作业网 时间:2024/10/06 13:46:06
x=0:0.001:2;y=humps(x);plot(x,y);如何求其最大值,需要matlab的程序?x=0:0.001:2;y=humps(x);plot(x,y);如何求其最大值,需要matl

x=0:0.001:2; y=humps(x); plot(x,y); 如何求其最大值,需要matlab的程序?
x=0:0.001:2; y=humps(x); plot(x,y); 如何求其最大值,需要matlab的程序?

x=0:0.001:2; y=humps(x); plot(x,y); 如何求其最大值,需要matlab的程序?
x = fminbnd(@(x)-humps(x),0,2)
对的 需要matlab程序,上面的程序可以算出来你要的最大值
humps是matlab内置的演示函数也就是驼峰曲线函数
fminbnd 是matlab求区间函数最小值的函数,区间是【0,2】.这里我用来求-humps的最小值,也就得出来相应的humps的最大值(x取值多少时候 函数最大)
@(x)-humps(x) 是matlab匿名函数的一种形式 研究下 不难的