please help me to execute the following code

2 次查看(过去 30 天)
if N_UE=[2 4 6 8 10]; N_SC=[20 30 40 50 60]; for t= 1:length(N_UE) for r = 1:length(N_SC) G=rand(t,r) end end B= zeros(t,r); N= 2; for g=1:N_SC(r) C= B(:,g); zeroidx = find(~C); replaceidx = zeroidx(randperm(numel(zeroidx), N-sum(C))); C(replaceidx) = 1 ; S(:,g) = [C]; end Z = G .* S
  5 个评论
Jan
Jan 2017-12-12
By the way: This overwrites G in each iteration by a growing matrix:
for t= 1:length(N_UE)
for r = 1:length(N_SC)
G = rand(t,r)
end
end
Replace this by:
G = rand(length(N_UE), length(N_SC));
Please post the complete error message. It contains a clear description of the problem. I guess, that the number of elements of S and C do not match. But without further explanations, it is not clear, which one is wanted.
Prabha Kumaresan
Prabha Kumaresan 2017-12-12
编辑:Torsten 2017-12-12
N_UE=[2 4 6 8 10];no of users
N_SC=[20 30 40 50 60];no of subcarriers
for t= 1:length(N_UE)
for r = 1:length(N_SC)
for k=1:N_SC(r)
for j=1:N_UE(t)
G(j,k)% G contains the values of j and k.
end
end
%subcarrier allocation to users
B= zeros(j,k);
N = 2;
for g=1:N_SC(r)
C= B(:,g);
zeroidx = find(~C);
replaceidx = zeroidx(randperm(numel(zeroidx), N-sum(C)));
C(replaceidx) = 1 ;
S(:,g) = [C];
end
Z = G .*S
end
end
If i run the code i am getting error in S(:,g) = [C] stating Subscripted assignment dimension mismatch.pls help me to solve this

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Thermodynamics & Statistical Physics 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by