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
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Thermodynamics & Statistical Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!