用FUNCTION搞定,怎么定义多元的如:y=x1*x2/x3?

MATLAB运用优化工具解决问题时,怎么定义多元函数。一元的:function=文件名(x);y=2*x^2;..

其中有要确定目标函数的么,用FUNCTION搞定,怎么定义多元的如:y=x1*x2/x3
菜鸟求助,问题白痴,多多包涵

人到中年有点甜
浏览 108回答 1
1回答

潇潇雨雨

如果是多元函数的话,可以参考fminseachExample 1The Rosenbrock banana function is a classic test example for multidimensional minimization:f=x(1)^2+a*x(2)^2; 目标函数 The minimum is at (1,1) and has the value 0. The traditional starting point is (-1.2,1). The anonymous function shown here defines the function and returns a function handle called banana:function f=myfun(x,a) 新建着这样的M文件banana = @(x)100*(x(2)-x(1)^2)^2+(1-x(1))^2;Pass the function handle to fminsearch:[x,fval] = fminsearch(banana,[-1.2, 1])  用这样的格式条用fminseach以及M函数, 其中[-1.2,1]为优化其实点This produces 运行以后的结果x =1.0000 1.0000fval = 这个是优化点的函数值8.1777e-010This indicates that the minimizer was found to at least four decimal places with a value near zero.
打开App,查看更多内容
随时随地看视频慕课网APP