How to calculate average

조회 수: 8 (최근 30일)
Dhawal Beohar
Dhawal Beohar 2019년 7월 10일
댓글: Dhawal Beohar 2019년 7월 21일
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));

채택된 답변

Image Analyst
Image Analyst 2019년 7월 10일
편집: Image Analyst 2019년 7월 10일
Did you try using sum()?
EHHH_avg = sum(EHH) / 100000;
  댓글 수: 5
Image Analyst
Image Analyst 2019년 7월 20일
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 2019년 7월 21일
Thank you ! it's being great help...

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by