how to remove the index number
1 次查看(过去 30 天)
显示 更早的评论
Could anybody help me how to remove the index number in for loop for the code mentioned below under the scenario it should not get repeated again in other group and for each run the matrix A should be updated.
A = diag([1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]);
N_G=4;%No of group
B = cell(N_G,1);
sumB = cell(N_G,1);
%
for i=1:1:N_G
n=randi([1 15],1)% select No of UE randomly
idx=randsample(1:size(A,2),n)
B{i} = A(idx,:)
%
[rows, columns] = size(B{i})
% Get sum of columns and replicate vertically.
sumB{i} = repmat(sum(B{i}, 1), [rows, 1])
end
2 个评论
Stephen23
2017-12-21
"Could anybody help me how to remove the index number in for loop for the code mentioned below "
What index you want to remove? From where, precisely?
"under the scenario it should not get repeated again in other group and for each run the matrix A should be updated."
What does this mean? Please explain in detail.
采纳的回答
Image Analyst
2017-12-21
It's not clear what you mean. A for loop has to have an index (loop iteration variable), though you're free to use it or ignore it in the loop. Also if you want A to change (somehow) in the loop, you're going to have to have A on the left side of an equals sign.
3 个评论
Image Analyst
2017-12-22
It looks like code I've given you at some point but that you've tried to modify to do something else. But I don't know what you're trying to do. For example, what is this line supposed to do:
for t= numGroups:length(N_UE)
This is essentially
for t= numGroups:numGroups
which means it will execute only once. I think you just need to think it through some more.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!