How to calculate average
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dhawal Beohar
le 10 Juil 2019
Commenté : Dhawal Beohar
le 21 Juil 2019
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));
0 commentaires
Réponse acceptée
Image Analyst
le 10 Juil 2019
Modifié(e) : Image Analyst
le 10 Juil 2019
Did you try using sum()?
EHHH_avg = sum(EHH) / 100000;
5 commentaires
Image Analyst
le 20 Juil 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');
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Labels and Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!