Filter löschen
Filter löschen

please help me to solve the issue:

2 Ansichten (letzte 30 Tage)
Prabha Kumaresan
Prabha Kumaresan am 22 Dez. 2017
Kommentiert: John D'Errico am 23 Dez. 2017
clear all
clc
%-----Simulation Parameters-----%
Bmax=2000000; %maximum available bandwidth for OFDMA
noise=1e-9; %fixed noise power is assumed
p_fix=0.01; %fixed transmit power is assumed
N_UE=[10 20 30 40 50];
N_SC=[60 70 80 90 100];
for it=1:2
for t= 1:length(N_UE)
%-----Topology-----%
Xmax=1; % x-coordinate for base station
Ymax=1; % y-coordinate for base station
radius=5; %coverage radius
xsd=ones(1,N_UE(t))*Xmax;
ysd=ones(1,N_UE(t))*Ymax;
rrx=radius*sqrt(rand(1,N_UE(t)));
thetarx=2*pi*rand(1,N_UE(t));
ang=0:0.01:2*pi;
xrx=xsd+rrx.*cos(thetarx); %random position of receivers-->x-coordinate
yrx=ysd+rrx.*sin(thetarx); %random position of receivers-->x-coordinate
th = 0:pi/100:2*pi;
xunit = radius * cos(th) + Xmax;
yunit = radius * sin(th) + Ymax;
% figure
% plot(xunit, yunit);
% hold on
% plot(ysd,xsd,'r^')
% hold on
% plot(yrx,xrx,'ko')
% hold on
%-----Subcarrier Correlation Matrix-----%
ratio=0.1; %Td over Tb: delay spread relative to OFDM frame duration
c=2*pi*ratio;
for r = 1:length(N_SC)
for j=1:N_UE(t)
temp=[];
for n=1:N_SC(r)
nc=(n-1)*c;
entry=(1+i*nc)/(1+nc^2);
temp=[temp entry];
end
Rchan=toeplitz(temp);
%autocorrelation matrix
[E,L]=eig(Rchan);
SQRTL=sqrt(L);
A=E*SQRTL/sqrt(2);
GG=randn(N_SC(r), 1)+i*randn(N_SC(r),1);
H=A*GG;
HH=abs(H);
% figure
% plot(abs(H))
% hold on
for k=1:N_SC(r)
F(j,k)=HH(k);
end
end
%-----Subcarrier Gain-----%
as=4;
bs=10;
Lsigma=as+(bs-as)*rand(1,N_UE(t));
Lshadow=10.^(randn(1,N_UE(t)).*(Lsigma/10));
ae=3;
be=5;
Lexp=ae+(be-ae)*rand(1,N_UE(t));
for k=1:N_SC(r)
for j=1:N_UE(t)
dist2(j)=sqrt((xrx(j)-xsd(j))^2+(yrx(j)-ysd(j))^2);
G(j,k)=(F(j,k)*Lshadow(j))/dist2(j).^Lexp(j);
end
end
%subcarrier allocation to users%
siz = size(G);
idx = sub2ind(siz, randi([1,N_UE(t)], 1, siz(2)), 1:siz(2));
C = zeros(siz);
C(idx) = G(idx);
D=sum(C,2);
% Throughput performance %
throughput =((Bmax.*log(1+((p_fix).*C))./noise));
overall_throughput = sum(sum(throughput));
output(t,r)=overall_throughput;
output_it(t,r,it)=output(t,r);
% figure
% plot(overall_throughput,'b','linewidth',2);
% legend(['No.of subcarriers=' num2str(N_SC(r))])
% xlabel('No of users')
% ylabel('overall_throughput')
% axis square
% grid on
end
end
end
out = sum(output_it,3);
final = out./2;
%Group formation%
N_G=5;%No of group
B = cell(N_G,1);
sumB = cell(N_G,1);
for d=1:1:N_G
if d==1
e=randi([1 5],1)% select No of UE randomly
else
sz=length(C(:,1));
e=randi([1 sz],1)% select No of UE randomly
end
idx=randsample(1:size(C,1),e)
B{d} = C(idx,:)
% C(idx,:) = [];
[rows, columns] = size(B{d});
% Get sum of columns and replicate vertically.
sumB{d} = repmat(sum(B{d},1), [rows, 1]);
end
E=[sumB{1}; sumB{2};sumB{3};sumB{4};sumB{5}];
The code gets execueted. But the size of the array in the command line
E=[sumB{1}; sumB{2};sumB{3};sumB{4};sumB{5}]
command is not same as the input (50,100).Could anybody help me solve this issue.
  2 Kommentare
Stephen23
Stephen23 am 22 Dez. 2017
"But the size of the array in the command line... is not same as the input (50,100)"
Why should it be? You use randsample to pick a random number of rows.
John D'Errico
John D'Errico am 23 Dez. 2017
Will you please stop asking the identical question multiple times? You asked this question twice. That is one reason you have asked now 117 questions, Almost all of them have been asked at least twice.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

ANKUR KUMAR
ANKUR KUMAR am 22 Dez. 2017
You have used
randsample(1:size(C,1),e)
in between of the program. Just because of this, you are getting F of different dimensions.
  3 Kommentare
Stephen23
Stephen23 am 22 Dez. 2017
Bearbeitet: Stephen23 am 22 Dez. 2017
@Prabha Kumaresan: change your code.
It is your code, so surely you understand how it works.
Why do you expect other people to work through your code and figure out what it does and how it works, if you are not prepared to put in any effort yourself?
Image Analyst
Image Analyst am 22 Dez. 2017
Prabha, HERE is how to solve it, guaranteed: CLICK HERE

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Numeric Types finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by