亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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

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

人到中年有點甜 2023-04-23 22:18:13
MATLAB運用優化工具解決問題時,怎么定義多元函數。一元的:function=文件名(x);y=2*x^2;..其中有要確定目標函數的么,用FUNCTION搞定,怎么定義多元的如:y=x1*x2/x3菜鳥求助,問題白癡,多多包涵
查看完整描述

1 回答

?
瀟瀟雨雨

TA貢獻1833條經驗 獲得超4個贊

如果是多元函數的話,可以參考fminseach
Example 1

The 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.0000

fval = 這個是優化點的函數值

8.1777e-010

This indicates that the minimizer was found to at least four decimal places with a value near zero.

查看完整回答
反對 回復 2023-04-25
  • 1 回答
  • 0 關注
  • 194 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號