i am getting an error "Index exceeds the number of array elements (2).", please can someone correct it. thanks in advance
1 view (last 30 days)
Show older comments
usman ali
on 14 Aug 2020
Answered: Walter Roberson
on 14 Aug 2020
K=2;
r=0.75;
tau=1-(K/T);
L=1;
N=K;
t=100;
L=1;
N=K;
t=100;
Z=1;
T=100;
Pt=0.199;
Pb=0.6;
NoAntenna=[5 10 15 20 25 30 35 40 45 50];
Slul=0;
phi22=0;
a=zeros(L,L,N);
b=zeros(L,L,N);
c1=zeros(1,T);
c2=zeros(1,T);
c3=zeros(1,T);
c4=zeros(1,T);
c5=zeros(1,T);
c6=zeros(1,T);
c7=zeros(1,T);
c8=zeros(1,T);
c9=zeros(1,T);
c10=zeros(1,T);
for S=1:T
phi1=zeros(N,L);
phi2=zeros(N,L);
phi3=zeros(N,L);
phi4=zeros(N,L);
d=(poissrnd(r,L,N,L))/1000;
B=10.^(-13.9 - 3.5*log(d) + 0.8*randn(L,N,L));
G=10.^(-13.9 - 3.5*log(d) + 0.8*randn(L,N,L));
for k=1:N
for g=1:L
for z=1:L
Slul=Slul+Pt*t*B(g,k,z);
end
b(:,g,k)=B(:,k,g)/sqrt((1+Slul));
g=g+1;
end
Slul=0;
k=k+1;
end
for k=1:N
a(:,:,k)=inv(b(:,:,k));
k=k+1;
end
M=NoAntenna(1);
c1(S)=tau*log(2)*(1+Pb*b(M-2));
M=NoAntenna(2);
c2(S)=tau*log(2)*(1+Pt*b(M-2));
M=NoAntenna(3);
c3(S)=tau*log(2)*(1+Pt*b(M-2));
M=NoAntenna(4);
c4(S)=tau*log(2)*(1+Pt*b(M-2));
M=NoAntenna(5);
c5(S)=tau*log(2)*(1+Pt*b(M-2));
M=NoAntenna(6);
c6(S)=tau*log(2)*(1+Pt*b(M-2));
M=NoAntenna(7);
c7(S)=tau*log(2)*(1+Pt*b(M-2));
M=NoAntenna(8);
c8(S)=tau*log(2)*(1+Pt*b(M-2));
M=NoAntenna(9);
c9(S)=tau*log(2)*(1+Pt*b(M-2));
M=NoAntenna(10);
c10(S)=tau*log(2)*(1+Pt*b(M-2));
end
c=[sum(c1) sum(c2) sum(c3) sum(c4) sum(c5)...
sum(c6) sum(c7) sum(c8) sum(c9) sum(c10)]./T
0 Comments
Accepted Answer
Walter Roberson
on 14 Aug 2020
d=(poissrnd(r,L,N,L))/1000;
d is fairly likely to have entries that are 0.
B=10.^(-13.9 - 3.5*log(d) + 0.8*randn(L,N,L));
Those 0 entries get log(0) which is infinite, so you start getting nan,and the rest of your calculation gets ruined.
b(M-2)
b only has 2 elements but M is 5. Is it possible you want to multiply b by M-2 instead of indexing b and M-2 ?
0 Comments
More Answers (0)
See Also
Categories
Find more on Robust Control Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!