Calculating throughput for users for 10000 times

3 ビュー (過去 30 日間)
Maheen Fazal
Maheen Fazal 2019 年 1 月 25 日
コメント済み: Jan 2019 年 4 月 28 日
Hi,i want to find the throughput of N users which are from 1 to 20,I defined it in a vector beacuse i want to run 10000 times for single user up to 20 and used another loop within the loop,after calculating the Throughput i am adding it in count and saving in variable count beacuse of 10000values,the value of count is divided by no of simulations i have run and save in S for user 1 to 2 and in the end ploting it ,but i am getting a straight decreasing graph,can any body help me to find the mistake i am doing???
clear all
close all
clc
simulations=10000;
n_vec=1:2:20;
R=[];
for n=n_vec
count=0;
S=0;
for sim=1:simulations
B=0.3;
phi=(1-B)./n;
tau=B./n;
Bbn=20*1000;
Rbn = phi*Bbn;
BR=n.*Rbn;
PRn=0.0002224 ;
Ehn=(1-B-phi)*PRn;
Ptr=Ehn/tau;
Kn=0.6;
Bandwidth=100*1000;
Psi=Kn*Bandwidth;
No=-174;
hn=rand;
po=No/hn;
gema=1/po;
Rhn=tau*Psi*log2(1+gema*Ehn/tau);
TR=n.*Rhn;
RTotal=BR+TR;
count=count+RTotal;
end
S=count./simulations;
R=[R S];
end
plot(n_vec,R)

回答 (1 件)

Jan
Jan 2019 年 1 月 25 日
編集済み: Jan 2019 年 1 月 25 日
I cannot follow your explanations. I start with cleaning your code:
simulations = 10000;
n_vec = 1:2:20;
R = zeros(1, simulations); % Pre-allocate
% Move constants out of the loop:
B = 0.3;
PRn = 0.0002224 ;
Bbn = 20*1000;
Kn = 0.6;
Bandwidth = 100*1000;
Psi = Kn*Bandwidth;
No = -174;
for in = 1:numel(n_vec)
n = n_vec(in);
phi = (1 - B) ./ n;
tau = B ./ n;
Rbn = phi * Bbn;
BR = n .* Rbn;
Ehn = (1 - B - phi) * PRn;
Ptr = Ehn/tau;
count = 0;
for sim = 1:simulations
TR = n .* tau * Psi * log2(1 + rand * Ehn / tau / No);
RTotal = BR + TR;
count = count + RTotal;
end
S = count ./ simulations;
R(in) = S;
end
plot(n_vec, R)
Yes, this looks almost like a straight line, but is is none:
diff(R)
You see, the differences are from -0.076 to -0.085. This is exactly what the given code instructs Matlab to calculate. The effects of the rand value are damped massively, by dividing it by a large value and adding 1 - and by takeing the log2 afterwards:
TR = n .* tau * Psi * log2(1 + rand * Ehn / tau / No)
= n .* tau * Psi * log2(1 + rand * ([-5.9e-6 to -5.9e-5]))
So if the value of rand is 0 or 1 changes the value of TR marginally only.
There is no chance to guess, why you expect another result or why you assume, that there is a mistake.
  3 件のコメント
K Venkatesh
K Venkatesh 2019 年 4 月 27 日
how to Calculating throughput for muti-hop routing in wireless network.
Ex. source (s) to destination (d)
path is: s -r2-r4-d (r2 and r4 Relay nodes)
plz help me
Jan
Jan 2019 年 4 月 28 日
@K Venkatesh: Please do no hijack another thread by injecting a new question in the comments and as an answer. Open a new thread by asking your own question. Mention more details there, because the current explanations are too lean to be answered.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by