Unable to perform assignment because the indices on the left side are not compatible with the size of the right side. Can anyone please help, Thanks in advance.

1 次查看(过去 30 天)
Error in UvsPs (line 39)
muo(i) = (-1./u).*log(((d1.^m)./(a.*n.*PsByN_0.*T.*u+d1.^m).*a)./(1-a));
clc
clear all;
d1=20;
d2=20;
n=10^-11.4;
m=2.7;
a=0.4;
T=1;
PsByN_0dB=[20:.01:40];
PsByN_0=10.^(PsByN_0dB/10);
UmaxdB = 15;
UmaxN_0=10.^(UmaxdB/10);
Qu=[-2:0.001:0];
QoS_Component_u=10.^(Qu);
for i=1:length(QoS_Component_u)
u=QoS_Component_u(i);
muo_sum(i)=0; %Initialising mu_o equal to zero
mui_sum(i)=0; %Initialising mu_i equal to zero
r1_sum(i)=0;
r2_sum(i)=0;
for j=1:100
hx1=(1/sqrt(2))*randn(1,1);
hy1=(1/sqrt(2))*randn(1,1);
h1=hx1.^2+hy1.^2;
hx2=(1/sqrt(2))*randn(1,1);
hy2=(1/sqrt(2))*randn(1,1);
h2=hx2.^2+hy2.^2;
muo(i) = (-1./u).*log(((d1.^m)./(a.*n.*PsByN_0.*T.*u+d1.^m).*a)./(1-a));
muo_sum(i)=muo_sum(i)+muo(i); %Summation of muo(i)
mui(i) = (1./u).*log(((-exp(u.*UmaxN_0).*(exp(-PsByN_0.*u)))./(u.*UmaxN_0+PsByN_0.*u)).*(PsByN_0.*u)-(PsByN_0.*u.*(exp(-PsByN_0.*u))).*(expint(u.*UmaxN_0+PsByN_0.*u))+(exp(-PsByN_0.*u))+((PsByN_0.*u).*(exp(-PsByN_0.*u))).*(expint(PsByN_0.*u))+(exp(u.*UmaxN_0))./((UmaxN_0./PsByN_0)+1));
mui_sum(i)=mui_sum(i)+mui(i); %Summation of mui(i)
r1(i) = log(1+(h1*PsByN_0)/(n*d1^m))*((1-a)*(T/2));
r1_sum(i) = r1_sum(i)+r1(i);
r2(i) = log(1+(h2*muo(i))/(n*d2^m))*((1-a)*(T/2));
r2_sum(i) = r2_sum(i)+r2(i);
end
muo_avg(i) = muo_sum(i)/100; %Average
mui_avg(i) = mui_sum(i)/100; %Average
r1_avg(i) = r1_sum(i)/100;
r2_avg(i) = r2_sum(i)/100;
C(i) = min(r1_avg(i),r2_avg(i));
end
loglog(QoS_Component_u,PsByN_0dB);
hold on;
grid on;

采纳的回答

Torsten
Torsten 2022-6-12
编辑:Torsten 2022-6-12
muo(i) = (-1./u).*log(((d1.^m)./(a.*n.*PsByN_0(i).*T.*u+d1.^m).*a)./(1-a));
instead of
muo(i) = (-1./u).*log(((d1.^m)./(a.*n.*PsByN_0.*T.*u+d1.^m).*a)./(1-a));
Same at several other locations within the j-loop.
The j-loop doesn't seem to make sense for me. What is its purpose ?

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by