matlab Unbalanced or unexpected parenthesis or bracket.本人初学者,clc;clear;Ps=0.01; sigma=10^(-4);W=10^6;a=0.01;W1=a*W/log(2); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% R=50;%%%%%%%%%随机生成中继节点位置xs=-50;%源节点ys=0; xd=50;%目
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/25 01:42:35
matlab Unbalanced or unexpected parenthesis or bracket.本人初学者,clc;clear;Ps=0.01; sigma=10^(-4);W=10^6;a=0.01;W1=a*W/log(2); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% R=50;%%%%%%%%%随机生成中继节点位置xs=-50;%源节点ys=0; xd=50;%目
matlab Unbalanced or unexpected parenthesis or bracket.本人初学者,
clc;clear;
Ps=0.01;
sigma=10^(-4);W=10^6;a=0.01;W1=a*W/log(2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
R=50;%%%%%%%%%随机生成中继节点位置xs=-50;%源节点ys=0;
xd=50;%目的节点yd=0;rho=rand(1)*R;theta=rand(1)*2*pi;x1=rho*cos(theta);%中继节点R1y1=rho*sin(theta);rho=rand(1)*R;theta=rand(1)*2*pi;x2=rho*cos(theta);%中继节点R2
y2=rho*sin(theta);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%dr1r2=sqrt((x2-x1)^2+(y2-y1)^2);%R1与R2之间的距离
dsr1=sqrt((x1+50)^2+(y1)^2);%S与R1之间的距离
dsr2=sqrt((x2+50)^2+(y2)^2);%S与R1之间的距离dr1d=sqrt((x1-50)^2+(y1)^2);%D与R1之间的距离dr2d=sqrt((x2-50)^2+(y2)^2);%R2与D之间的距离
dsd=100;%S与D之间的距离Gsr1=(dsd/dsr1)^2;Gsr2=(dsd/dsr2)^2;Gr1d=(dsd/dr1d)^2;Gr2d=(dsd/dr2d)^2;Gsd=1;
A1=Ps*Gsr1/(sigma^2+Ps*Gsd);
A2=Ps*Gsr2/(sigma^2+Ps*Gsd);B1=(Ps*Gsr1+sigma^2)/Gr1d;B2=(Ps*Gsr2+sigma^2)/Gr2d;
syms p1 p2;%只有价格p1 p2是符号变量
c1=0.1;c2=0.1;p11=0.1;p22=0.1;
X=1+A1+A2;Y=sqrt(p1*A1*B1)+sqrt(p2*A2*B2);%p1,p2是节点的报价,刚开始时是c1,c2Pr1o=sqrt(A1*B1/p1)*(Y+sqrt(Y^2+4*X*W1)/(2*X)-B1;%是报价的函数
Pr2o=sqrt(A2*B2/p2)*(Y+sqrt(Y^2+4*X*W1)/(2*X)-B2;
最后两行报错
matlab Unbalanced or unexpected parenthesis or bracket.本人初学者,clc;clear;Ps=0.01; sigma=10^(-4);W=10^6;a=0.01;W1=a*W/log(2); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% R=50;%%%%%%%%%随机生成中继节点位置xs=-50;%源节点ys=0; xd=50;%目
最后两行的括号少了半边 ,Y前的括号
Pr1o=sqrt(A1*B1/p1)*(Y+sqrt(Y^2+4*X*W1)/(2*X)-B1;%是报价的函数
Pr2o=sqrt(A2*B2/p2)*(Y+sqrt(Y^2+4*X*W1)/(2*X)-B2;