tamoor
Newbie level 6
there is something wrong, please help me set it :
here is the code:
Part 1: No-Relay Transmitted power
Pr = 10^-3; % Rx. power requirement of the M.S
dt = 2000; % Fixed distance from B.S to M.S
y=4; % Pathloss exponent in urban areas
Ptbm = Pr*(dt^y); % Calculate power transmitted in No relay system
PtbmdB = pow2dB(Ptbm) % Convert Milli Watts into dB
norelay=PtbmdB;
contnplot=0:1:2000; % For continuous graph
% Part 2: Relay Transmitted Power (Two-hop transmission)
dr = 0:50:2000 % distance at which RS is placed between BS & MS
for count1=1:41 % To calculate multiple values of Tx. Power
Ptb(count1)= (Pr*((dr(count1))^y)); % Calc. Tx Pwr from BS to RS
Ptr(count1)= (Pr*((dt-dr(count1))^y)); % Calc. Tx Pwr from RS to MS
Ptm(count1)=Ptb(count1)+ Ptr(count1); % Calc. total Tx Pwr
PtmdB(count1)= pow2dB(Ptm(count1)) % Convert Milli Watts into dB
Ptmin=min(PtmdB) % Find the minimum Tx. pwr
% find the distance at which minimum Tx. Pwr is achieved
if PtmdB(count1)== Ptmin
dmin = dr(count1);
end
end
% Part 3: Plot the graph
figure,
hold on % To plot the graph at the same plot
xlabel('Distance');
ylabel('Tx Power in dBm');
title('Tx. Power v/s distance')
xlim([0 2000]);
ylim([80 110]);
p1=plot(dr,PtmdB,'ro-'); % Plot the graph for Tx. Pwr in No Relay
p2=plot(contnplot,norelay); % Plot the graph for Tx. Pwr in Relay Tx.
p3=plot(dmin,Ptmin,'*'); % To plot the Min. Tx. Pwr in Relay Tx.
legend('Simple Relay', 'No Relay' , 'Optimum Power level');
hold off;
here is the code:
Part 1: No-Relay Transmitted power
Pr = 10^-3; % Rx. power requirement of the M.S
dt = 2000; % Fixed distance from B.S to M.S
y=4; % Pathloss exponent in urban areas
Ptbm = Pr*(dt^y); % Calculate power transmitted in No relay system
PtbmdB = pow2dB(Ptbm) % Convert Milli Watts into dB
norelay=PtbmdB;
contnplot=0:1:2000; % For continuous graph
% Part 2: Relay Transmitted Power (Two-hop transmission)
dr = 0:50:2000 % distance at which RS is placed between BS & MS
for count1=1:41 % To calculate multiple values of Tx. Power
Ptb(count1)= (Pr*((dr(count1))^y)); % Calc. Tx Pwr from BS to RS
Ptr(count1)= (Pr*((dt-dr(count1))^y)); % Calc. Tx Pwr from RS to MS
Ptm(count1)=Ptb(count1)+ Ptr(count1); % Calc. total Tx Pwr
PtmdB(count1)= pow2dB(Ptm(count1)) % Convert Milli Watts into dB
Ptmin=min(PtmdB) % Find the minimum Tx. pwr
% find the distance at which minimum Tx. Pwr is achieved
if PtmdB(count1)== Ptmin
dmin = dr(count1);
end
end
% Part 3: Plot the graph
figure,
hold on % To plot the graph at the same plot
xlabel('Distance');
ylabel('Tx Power in dBm');
title('Tx. Power v/s distance')
xlim([0 2000]);
ylim([80 110]);
p1=plot(dr,PtmdB,'ro-'); % Plot the graph for Tx. Pwr in No Relay
p2=plot(contnplot,norelay); % Plot the graph for Tx. Pwr in Relay Tx.
p3=plot(dmin,Ptmin,'*'); % To plot the Min. Tx. Pwr in Relay Tx.
legend('Simple Relay', 'No Relay' , 'Optimum Power level');
hold off;