Continuing the discussion from Convergence Graph:
code:
function [ch,Ld] = ricianCh(chSize, ricianFactor, dist, pathLossRef, distRef, pathLossExp, freq, phi)
if ~isequal(size(chSize), [1 2]) || ~isreal(chSize)
disp(‘ERROR! input chSize must be in size of 2x1 and real’);
disp('your chSize : ‘); disp(chSize);
error(’ ‘);
end
if ~isreal(ricianFactor) || ~isscalar(ricianFactor) || ricianFactor<0
disp(‘ERROR! input kappa must be a real scalar positive’);
disp(‘your kappa :’); disp(ricianFactor);
error(’ ‘);
end
if ~isreal(dist) || ~isscalar(dist) || dist<0
disp(‘ERROR! input dist must be a real scalar positive’);
disp(‘your dist :’); disp(dist);
error(’ ‘);
end
if ~isreal(pathLossRef) || ~isscalar(pathLossRef) || pathLossRef<0
disp(‘ERROR! input pathLossRef must be a real scalar positive’);
disp(‘your pathLossRef :’); disp(pathLossRef);
error(’ ‘);
end
if ~isreal(distRef) || ~isscalar(distRef) || distRef<0
disp(‘ERROR! input distRef must be a real scalar positive’);
disp(‘your distRef :’); disp(distRef);
error(’ ‘);
end
if ~isreal(pathLossExp) || ~isscalar(pathLossExp) || pathLossExp<0
disp(‘ERROR! input pathLossExp must be a real scalar positive’);
disp(‘your pathLossExp :’); disp(pathLossExp);
error(’ ‘);
end
if ~isreal(freq) || ~isscalar(freq) || freq<0
disp(‘ERROR! input freq must be a real scalar positive’);
disp(‘your freq :’); disp(freq);
error(’ ');
end
Ld = pathLossRef*((dist/distRef)^(-pathLossExp)); %disp(['Ld : ', num2str(Ld)]);
waveLen = 3e8/freq; %disp(['waveLen : ‘, num2str(waveLen)]);
k = 2pi/waveLen; %disp([‘k : ‘, num2str(k)]);
N_ar = chSize(1); rowCnt = (0:(N_ar-1)).’; %disp(‘N_ar :’); disp(N_ar);
N_at = chSize(2); colCnt = (0:(N_at-1)).’; %disp(‘N_at :’); disp(N_at);
d_a = waveLen/2; %disp(‘d_a :’); disp(d_a);
ar = (1/sqrt(N_ar))exp(1jkd_arowCntsin(phi)); %disp(‘ar :’); disp(ar);
at = (1/sqrt(N_at))exp(1jkd_acolCntsin(phi)); %disp(‘at :’); disp(at);
H_NLOS = randn(chSize) + 1jrandn(chSize); %disp(‘H_NLOS :’); disp(H_NLOS);
ch = sqrt(Ld)*(sqrt(ricianFactor/(1+ricianFactor))arat’ + sqrt(1/(1+ricianFactor))*H_NLOS);
end