Hi. I have an equation below for which I need to calculate the average value for mu_o.
First, by calculating the sum of it, and secondly by dividing it with no of iterations, but I am unable to do it. Please help it's urgent!
I am doing for mu_o the same as I have calculated the average for EHH but I am not getting correct values.
rt=2;
NoB=1;
Pmax=100;
EHH(i)=0;
mu_o(i)=0[
for j=1:100000
mu_o(i)= mu_o(i)+ min((((exp(rt)-1)*NoB)./r),Pmax);
EHH(i)=EHH(i)+exp(ii*mu_o);
end
EHHH_avg(i)=(EHH(i))/100000;
mufix(i)=(1/ii)*log(EHHH_avg(i));
mu_o_avg(i)=(mu_o(i))/100000;
Epsilon=((mu_o_avg(i))/mufix(i));

 Respuesta aceptada

Image Analyst
Image Analyst el 10 de Jul. de 2019
Editada: Image Analyst el 10 de Jul. de 2019

0 votos

Did you try using sum()?
EHHH_avg = sum(EHH) / 100000;

5 comentarios

Dhawal Beohar
Dhawal Beohar el 10 de Jul. de 2019
Hi, thanks for your reply.
i need to calculate average of mu_o(i), EHHH is fine.
And i have tried using sum and mean both but not getting correct values
Image Analyst
Image Analyst el 10 de Jul. de 2019
Please show your code to show why
EHHH_avg = sum(EHH) / 100000
mu_o_avg = sum(mu_o)/100000
is not working. What do they report, and what do you expect?
Dhawal Beohar
Dhawal Beohar el 11 de Jul. de 2019
Editada: Image Analyst el 11 de Jul. de 2019
clc
clear
NoB=1; % Noise Density
rt=0.5; % Rate in bits/sec
EH=0; % Initialising Energy Harvesting
Bmax= 50; % Threshold level of battery in Joules
Bslot= 3; % Energy threshold in Joules
Pout=[0.001:0.001:0.1];
QoS_Component_u=[0.001:0.001:0.1];
for i=1:length(QoS_Component_u)
u=QoS_Component_u(i);
Pmax=100;
EHH(i)=0;
muo_sum(i)=0;
for j=1:100000
hx=(1/sqrt(2))*randn(1,1);
hy=(1/sqrt(2))*randn(1,1);
ht_rayleigh=hx.^2+hy.^2;
muo=min((((exp(rt)-1)*NoB)./ht_rayleigh),Pmax);
muo_sum(i)=muo_sum(i)+muo;
EHH(i)=EHH(i)+exp(u*muo);
end
EHHH(i)=(EHH(i))/100000;
mufix(i)=(1/u)*log(EHHH(i));
mu_o_avg(i)=(muo_sum(i))/100000;
Epsilon(i)=((mu_o_avg(i))/mufix(i));
Pout(i)= (Epsilon(i)*(exp(-u*(mufix(i))*(Bmax-Bslot))));
end
plot(QoS_Component_u,Pout);
grid on;
hold on;
title('Comparison between Pout and QoS Component u');
xlabel('QoS Component u');
ylabel('Pout');
This is my complete code where i need to calculate the average of muo,and i am calculating it by calculating summation and then by dividing it by iterations.I want to do it this way and not by using sum function.
Also everytime it is giving me different values for muo,why?
Please Help.
Image Analyst
Image Analyst el 20 de Jul. de 2019
See if this works for you:
clc
clear
close all;
fprintf('Working...\n');
NoB=1; % Noise Density
rt=0.5; % Rate in bits/sec
EH=0; % Initialising Energy Harvesting
Bmax= 50; % Threshold level of battery in Joules
Bslot= 3; % Energy threshold in Joules
Pout=[0.001:0.001:0.1];
QoS_Component_u=[0.001:0.001:0.1];
maxj = 100000;
for i=1:length(QoS_Component_u)
u=QoS_Component_u(i);
Pmax=100;
muo = zeros(1, maxj);
EHH = zeros(1, maxj);
for j = 1 : maxj
hx=(1/sqrt(2))*randn(1,1);
hy=(1/sqrt(2))*randn(1,1);
ht_rayleigh = hx.^2 + hy.^2;
muo(i) = min((((exp(rt)-1)*NoB)./ht_rayleigh),Pmax);
EHH(i) = EHH(i)+exp(u*muo(i));
end
EHHH(i)= mean(EHH);
mufix(i)=(1/u)*log(EHHH(i));
mu_o_avg(i)= mean(muo);
Epsilon(i)=((mu_o_avg(i))/mufix(i));
Pout(i)= (Epsilon(i)*(exp(-u*(mufix(i))*(Bmax-Bslot))));
end
plot(QoS_Component_u, Pout, 'LineWidth', 2);
grid on;
hold on;
title('Comparison between Pout and QoS Component u', 'FontSize', 13);
xlabel('QoS Component u', 'FontSize', 13);
ylabel('Pout', 'FontSize', 13);
fprintf('Done!\n');
Dhawal Beohar
Dhawal Beohar el 21 de Jul. de 2019
Thank you ! it's being great help...

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Labels and Annotations en Centro de ayuda y File Exchange.

Preguntada:

el 10 de Jul. de 2019

Comentada:

el 21 de Jul. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by