this is my code:
pathloss2 = zeros(50,8);
f = 2500;
height = 5; % height of the base station(b/w 10 t0 80 meters)
do = 100; % constant
% d=500; %d>do
% s=8; % typical value of standard deviation (b/w 8 and 10 dB)
wavelength = 3.0e+8/f;
atype = 4.6; % model parameters
btype = 4;
ctype = 3.6;
gamma = (atype-btype*height+ctype/height);
A = 20*log10(4*3.14*do/wavelength);
deltaPLf = 6*log10(f/2000);
deltaPLh = -10.8*log10(height/1.5);
UserLocationX = randi(50, 1, 50);
UserLocationY = randi(50, 1, 50);
AccessPointX = randi(50, 1, 8);
AccessPointY = randi(50, 1, 8);
dis = sqrt((UserLocationX(:,1)-AccessPointX).^2 + (UserLocationY(:,2)-AccessPointY).^2);
for k=1:50
for l=1:8
PL = A+10*gamma*log10(dis(k,l)/do*1000);
pathloss2(k,l)= PL + deltaPLf + deltaPLh + 30;
end
end

 Respuesta aceptada

Image Analyst
Image Analyst el 18 de Abr. de 2014
Bring dis inside the loop. Try this:
UserLocationX = randi(50, 1, 50);
UserLocationY = randi(50, 1, 50);
AccessPointX = randi(50, 1, 8);
AccessPointY = randi(50, 1, 8);
for k=1:50
for l=1:8
distance = sqrt((UserLocationX(k)-AccessPointX(l)).^2 + (UserLocationY(k)-AccessPointY(l)).^2);
PL = A+10*gamma*log10(distance/do*1000);
pathloss2(k,l)= PL + deltaPLf + deltaPLh + 30;
end
end

4 comentarios

abdulaziz alofui
abdulaziz alofui el 18 de Abr. de 2014
does not work ......its same problem
Walter Roberson
Walter Roberson el 18 de Abr. de 2014
Which line is the error showing up on, and what is the exact error message?
abdulaziz alofui
abdulaziz alofui el 18 de Abr. de 2014
Index exceeds matrix dimensions.
this line : PL = A+10*gamma*log10(distance(k,l)/do*1000);
Image Analyst
Image Analyst el 18 de Abr. de 2014
That's not the code I gave you!!!!

Iniciar sesión para comentar.

Más respuestas (2)

Sara
Sara el 17 de Abr. de 2014

0 votos

The variable dis is 1 by 8 while you ask the code to access dis(k,l) with k from 1 to 50

2 comentarios

abdulaziz alofui
abdulaziz alofui el 17 de Abr. de 2014
no the variable dis its mean the distance b/w 50 random userlocation and 8 random access point
Sara
Sara el 17 de Abr. de 2014
I ran the code as is and that's what acme out. You'll need to change that variable expression if it is not what you expected.

Iniciar sesión para comentar.

Walter Roberson
Walter Roberson el 17 de Abr. de 2014

0 votos

UserLocationX = randi(50, 1, 50) is going to build UserLocationX as a row vector. UserLocationX(:,1) then asks for a particular column out of that row vector, and since there is only one row in the row vector the result is going to be a scalar.
Watch out for row versus column access.

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Preguntada:

el 17 de Abr. de 2014

Comentada:

el 18 de Abr. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by