Simulating rayleigh fading channel
14 views (last 30 days)
Show older comments
Hi, I am simulating a rayleigh fading channel. I am getting a "Subscripted assignment dimension mismatch" on line 31. I am trying to sample for 1000 samples.
Any help would be appreciated for the error.
Thanks,
if true
%Initial conditions
N = 16; %Scatters
fc = 2000000000; %Carrier frequency of wave
v = 27.78; %Velocity of wave in km/h
c = 300000000; %Speed of light
Cn = 1/sqrt(N);
E0 = 1;
Tc = 0;
Ts = 0;
T = 0:250;
tc = zeros(1002,1);
ts = zeros(1002,1);
for t = 1:length(T) %Simulate Rayleigh channel for 250 ms
for a = 1:1001
for n = 1:N %Simulate Rayleigh channel for 16 scattering paths
lambda = c/fc; %Wavelength
alphan = (2*pi*n)/N; %Doppler shift angle
fn = (v/lambda)*cos(alphan); %Doppler frequency
phin = 2*pi*rand(1); %Random phase on each scatter path
TC = Cn*cos(2*pi*fn*t + phin);
Tc = Tc + TC;
TS = Cn*sin(2*pi*fn*t + phin);
Ts = Ts + TS;
end
tc(a) = Tc;
ts(a) = Ts;
end
Ez(t) = abs(sqrt(tc.*tc + ts.*ts));
Ez_dB(t) = 20*log(Ez(t));
end
figure %Plotting power gain of envelope plot(T,Ez_dB),grid on; title(' Rayleigh Fading Channel over Time'); xlabel(' Time (ms) '); ylabel(' Power Gain (dB) ');
figure %Plotting envelope histogram hist(abs(Ez),20); title(' Rayleigh Fading Channel Envelope'); xlabel(' Envelope of E field '); ylabel(' Number of Times '); end
1 Comment
Answers (1)
Trooper
on 3 Mar 2018
Remove '(t)' from Ez(t) = abs(sqrt(tc.*tc + ts.*ts)); it will work then. Also what are you trying to do at
tc = zeros(1002,1); ts = zeros(1002,1); and tc(a) = Tc; ts(a) = Ts;
See Also
Categories
Find more on Propagation and Channel Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!