如何用Matlab做此函数的图形并求最小值

来源:百度知道 编辑:UC知道 时间:2024/04/28 02:53:50
function y=fun(x)
a=185*(3/(((x(1)^2)/4)+9)^0.5)^0.3
if x(1)<=64&x(2)<=a
y=ksi1+1./k1
elseif x(1)>64&x(2)<=a
y=ksi2+1./k2
elseif x(1)<=64&x(2)>a
y=ksi3+1./k3
elseif x(1)>64&x(2)>a
y=ksi4+1./k4
end
function ksi1=flow1(x)
ksi1=0.591*(1+1697*x(1)^(-1.6))*(100*x(2))^(-0.25*(1+1.986*x(1)^(-0.3))) %x(1)<=64&x(2)<=a
function ksi2=flow2(x)
ksi2=0.591*(1+7.23*10^6*x(1)^(-3.6))*(100*x(2))^(-0.25*(1+97.72*x(1)^(-1.2))) %x(1)>64&x(2)<=a
function ksi3=flow3(x)
ksi3=0.356*(1+1690*x(1)^(-2))*(100*x(2))^(-0.25) %x(1)<=64&x(2)>a
function ksi4=flow4(x)
ksi4=0.356*(1+7683*x(1)^(-2.5))*(100*x(2))^(-0.25) %x(1)>64&x(2)>a
function k1=heat1(x)
k1=0.0022*(1+116.9*x(1)^(-0.21))*(100*x(2))^(0.6*(1+0.01133*x(1)^(0.73))) %x(1)<=64&x(2)<=a
function k2=heat2(x)
k2=0.0022*(1+1.563*10^13

定义的函数有问题改为
function y=fun(x)
a=185*(3/(((x(1)^2)/4)+9)^0.5)^0.3 ;
if x(1)<=64&&x(2)<=a
y=flow1(x)+1./heat1(x) ;
elseif x(1)>64&&x(2)<=a
y=flow2(x) +1./heat2(x) ;
elseif x(1)<=64&&x(2)>a
y=flow3(x) +1./heat3(x) ;
elseif x(1)>64&&x(2)>a
y=flow4(x)+1./heat4(x) ;
end

要绘图的话 先给定x的区间,算出y 用plot或plot3(3维图)绘图

最小值可以用min来求或者用fminsearch函数