matlab Unbalanced or unexpected parenthesis or bracket.本人初学者
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/19 02:45:09
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;
最后两行报错
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;
最后两行报错
最后两行的括号少了半边 ,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;
再问: Price1=zeros(1,20); Price2=zeros(1,20); power1=zeros(1,20); power2=zeros(1,20); power1(1)=subs(Pr1o,p1,p11);%节点1在各节点都报价c(此时为了后面的整体行,用p11代替c1)时的最佳功率power2(1)=subs(Pr2o,p2,p22); 报错是The following error occurred converting from sym to double If the input expression contains a symbolic variable, usethe VPA function instead. 可以帮忙看下吗?
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;
再问: Price1=zeros(1,20); Price2=zeros(1,20); power1=zeros(1,20); power2=zeros(1,20); power1(1)=subs(Pr1o,p1,p11);%节点1在各节点都报价c(此时为了后面的整体行,用p11代替c1)时的最佳功率power2(1)=subs(Pr2o,p2,p22); 报错是The following error occurred converting from sym to double If the input expression contains a symbolic variable, usethe VPA function instead. 可以帮忙看下吗?
matlab 出错Error: Unbalanced or unexpected parenthesis or brac
matlab中输入下面语句显示Error:Unbalanced or unexpected parenthesis or
关于matlab的Error:Unbalanced or misused parentheses or brackets
MATLAB错误:Unbalanced or misused parentheses or brackets,
Pls translate the words or sentence parenthesis into Chinese
III.Rewrite each sentence with the word or phrase in bracket
Unexpected MATLAB operator.
matlab提示Error:Incomplete or misformed expression or statemen
matlab提示:Incomplete or misformed expression or statement.
matlab中Error:Missing variable or function.
本人初学者编了个MATLAB程序一直运行不成,求
Error: Unexpected MATLAB operator. 在线等,谢谢