| 查看: 274 | 回复: 1 | ||
[求助]
函数调用
|
|
这是我的目标函数,里面有随机生成数: 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=[]; 下面的是所用的计算函数: 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) 现在有个问题:在约束中的f3必须是目标函数中生成的那个f3,因为目标函数中的f3含有随机数,请问哪位大神能帮我下,在约束中调用目标函数中的那个f3! |
» 猜你喜欢
新西兰Robinson研究所招收全奖PhD
已经有0人回复
石墨烯转移--二氧化硅衬底石墨烯
已经有0人回复
物理学I论文润色/翻译怎么收费?
已经有83人回复
笼目材料中量子自旋液体基态的证据
已经有0人回复
数学教学论硕士可以读数学物理博士吗?
已经有0人回复
德国亥姆霍兹Hereon中心汉堡分部招镁合金腐蚀裂变SCC课题方向2026公派博士生
已经有4人回复
澳门大学 应用物理及材料工程研究院 潘晖教授课题组诚招博士后
已经有11人回复
求助NH4V4O10晶体的CIF文件
已经有0人回复
英国全奖博士招聘-深度学习与量子物理
已经有0人回复
间接带隙半导体有效质量求助
已经有1人回复
投稿chemical physical letters不送审?
已经有2人回复

2楼2012-11-20 12:01:26













回复此楼