| 2 | 1/1 | 返回列表 |
| 查看: 282 | 回復: 1 | |||
qiaoye32803新蟲 (初入文壇)
|
[求助]
函數(shù)調用
|
|
這是我的目標函數(shù),里面有隨機生成數(shù): function opforpaper=lq_paper(x) syms theta; mu_ra=0.0645; mu_rb=0.0889; mu_rc=0.043; sigma_ra=0.008; sigma_rb=0.07; sigma_rc=0.004; for i=1:100 f_1(i)=cos(theta)*(x(1)+x(3)*normrnd(0,1)+normrnd(mu_rb,sigma_rb)*cos(unifrnd(0,2*pi))-normrnd(mu_ra,sigma_ra)*cos(unifrnd(0,2*pi)))+sqrt((x(2)+x(4)*normrnd(0,1)+normrnd(mu_rc,sigma_rc)*cos(unifrnd(0,2*pi))).^2-(x(1)+x(3)*normrnd(0,1)+normrnd(mu_rb,sigma_rb)*cos(unifrnd(0,2*pi))-normrnd(mu_ra,sigma_ra)*sin(theta)).^2); f_2(i)=cos(theta+0.0063)*(x(1)+x(3)*normrnd(0,1)+normrnd(mu_rb,sigma_rb)*cos(unifrnd(0,2*pi))-normrnd(mu_ra,sigma_ra)*cos(unifrnd(0,2*pi)))+sqrt((x(2)+x(4)*normrnd(0,1)+normrnd(mu_rc,sigma_rc)*cos(unifrnd(0,2*pi))).^2-(x(1)+x(3)*normrnd(0,1)+normrnd(mu_rb,sigma_rb)*cos(unifrnd(0,2*pi))-normrnd(mu_ra,sigma_ra)*sin(theta+0.0063)).^2); f3(i)=abs(f_1(i)-f_2(i)); end opforpaper=mean(f3); 下面的是約束, function [c,ceq]=consfun(x) M=384; c=[(M*sqrt(M^2+f3^2)-M)/(2*sqrt(M^2+f3^2))-0.05;f3*M/(2*sqrt(M^2+f3^2))-0.5]; ceq=[]; 下面的是所用的計算函數(shù): clear x0=[50,335,0.005,0.05]; lb=[45,330,0.002,0.007]; ub=[55,340,0.02,0.07]; options=optimset('largescale','off','Algorithm','active-set'); [x,fval]=fmincon('lq_paper',x0,[],[],[],[],lb,ub,'consfun',options) 現(xiàn)在有個問題:在約束中的f3必須是目標函數(shù)中生成的那個f3,因為目標函數(shù)中的f3含有隨機數(shù),請問哪位大神能幫我下,在約束中調用目標函數(shù)中的那個f3! |
榮譽版主 (著名寫手)
彩色掛圖
![]() |
專家經(jīng)驗: +2 |

| 2 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 一志愿北京理工大學本科211材料工程294求調劑 +8 | mikasa的圍巾 2026-03-28 | 8/400 |
|
|---|---|---|---|---|
|
[考研] 279求調劑 +4 | 蝶舞輕繞 2026-03-29 | 4/200 |
|
|
[考研] 085600,專業(yè)課化工原理,321分求調劑 +5 | 大饞小子 2026-03-28 | 5/250 |
|
|
[考研] 330分求調劑 +5 | qzenlc 2026-03-29 | 5/250 |
|
|
[考研] 數(shù)一英一271專碩(085401)求調劑,可跨 +7 | 前行必有光 2026-03-28 | 8/400 |
|
|
[考研] 343求調劑 +5 | 愛羈絆 2026-03-28 | 5/250 |
|
|
[考研]
|
y7czhao 2026-03-26 | 10/500 |
|
|
[考研] 一志愿南師大0703化學 275求調劑 +4 | Ripcord上岸 2026-03-27 | 4/200 |
|
|
[考研] 07化學280分求調劑 +10 | 722865 2026-03-23 | 10/500 |
|
|
[考研] 308求調劑 +7 | 墨墨漠 2026-03-25 | 7/350 |
|
|
[考研] 312求調劑 +9 | 上岸吧ZJY 2026-03-22 | 13/650 |
|
|
[考研] 333求調劑 +6 | wfh030413@ 2026-03-23 | 6/300 |
|
|
[考研] 294分080500材料科學與工程求調劑 +4 | 柳溪邊 2026-03-26 | 4/200 |
|
|
[考研] 調劑 +4 | 柚柚yoyo 2026-03-26 | 4/200 |
|
|
[考研] 281求調劑 +3 | 亞克西good 2026-03-26 | 5/250 |
|
|
[考研] 一志愿河工大 081700 276求調劑 +4 | 地球繞著太陽轉 2026-03-23 | 4/200 |
|
|
[考研] 材料與化工304求B區(qū)調劑 +3 | 邱gl 2026-03-25 | 3/150 |
|
|
[考研] 求調劑 +3 | 李李不服輸 2026-03-25 | 3/150 |
|
|
[考研] 285求調劑 +3 | AZMK 2026-03-24 | 3/150 |
|
|
[考研] 328求調劑 +4 | LHHL66 2026-03-23 | 4/200 |
|