| 查看: 316 | 回复: 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! |
» 猜你喜欢
如何从铁电相到顺电相。
已经有1人回复
各位大佬,求一份最新Wien2k版本作为学习用途
已经有0人回复
物理学I论文润色/翻译怎么收费?
已经有235人回复
南科大活性流体和软物质课题组诚招2027级博士、硕士研究生和博后
已经有42人回复
瑞典林雪平大学博士后招聘|PEC Water Splitting 方向
已经有24人回复
PRB投稿,Acknowledgment sent to author状态十天了
已经有3人回复
PVA溶解
已经有2人回复
基金申请
已经有44人回复
CSC与新西兰维多利亚大学PhD奖学金项目
已经有0人回复
新西兰Robinson研究所 招聘CSC公派访问人员
已经有0人回复
帮我的英语口语老师找学生
已经有0人回复

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










回复此楼