How can I simulate a resource allocation?

6 次查看(过去 30 天)
Hi, I need help with creating code.
*************************************************
attached file
detected = vector of detected preambles.
the value of this vector is random, sometimes it can have 1 or ....... N values.
*************************************************
for example I have 50 resources available and I need to assign those resources to the detected preambles that would be the attached file (detected).
for example if I have 50 PRBs and I have 12 preambles in (detected) the algorithm would have to run only 12 times.
and if for example I had 10 PRBs and I have 12 preambles in (detected) the algorithm would only have to run 10 times, because there would be no more resources to allocate.
Thank you very much in advance

回答(1 个)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021-11-10
According to what you have stated in your exercise description and understood, this code can be written:
D = load('detected.mat');
if numel(PRBs)==50 && numel(D)>12
for ii=1:12
N(ii)=PRB(D(ii));
end
elseif numel(PRBs)==50 && numel(D)==12
for ii=1:12
N(ii)=PRB(D(ii));
end
else % numel(PRBs)==10 && numel(D)==12
for ii=1:10
N(ii)=PRB(D(ii));
end
end
  1 个评论
giancarlo maldonado cardenas
Hi, thanks for answering.
I think I did not explain myself well.
for example I will have a variable
prb = 50;
assigned = []; % empty vector to store.
for
end
in prb = 50, I have 50 positions available to give, so in the detected vector I have 12 values, those 12 values would be assigned in the first 12 positions of the variable prb = 50, and it would be stored in a new vector: assigned = []
************************************************** ******
now in another scenario that the prb variable is 10.
prb = 10;
assigned = [];
for
end
I have 10 positions available to give, but in the detected vector I have 12 values, therefore I can only assign 10 positions of the variable prb = 10. therefore 2 would be left out because it would not have more positions to give, and it would be stored in new vector: assigned = []. then it would show a message 'there are no more resources to allocate'

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 LTE Toolbox 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by