📄 multipathfadingchannel.m
字号:
% Simulation of multipath fading Channel% Observe the response of multipath fading channel to the pulses in time and freq domainsubplot(1,1,1) % Create axes in tiled positions (m,n,p), breaks the Figure window % into an m-by-n matrix of small axes, selects the p-th axes for % for the current plot, and returns the axis handle. % Initializationsfs = 1e7; % fs - sampling rate (e.g., 1e7 for 10000KHz), 1/fs=1e-7 secondf0=1e9; % f0 - carrier frequency (e.g., 1e9 for 1GHz)v=100; % v - vehicle speed in km/h (determines doppler frequency)tt = 0:1/fs:4.1e-3; % time range start 0s until 4.1e-3s=4.1ms step 1/fs=1e-7 second (41001 points)% input signal (an impulse once per millisecond)ss = zeros(size(tt));Delta = 1e-3; DeltaS = round(Delta*fs); % Round towards nearest integer, one pulse in every 10000 samplesss(1:DeltaS:length(ss)) = 1; % Prepare input signal s_in (5 pulses) to be fed into the channel, % Channel output rr: invoke fading multipath channel simulatorrr = RayleighFadingNoise2_GSM(ss, f0, fs, v, 1); % seed=1 - seed for random number generator% Results:% Multipath due to impulse at t=0stem(1e6*tt(1:60), real(rr(1:60)),'b'); % STEM(X,Y) plots the discrete data sequence Y versus X.xlabel('Time (\mus)')title('Channel response for \delta(t)')pause% Fouriertransform of response to first pulseff=0:10e3:5e6;RR = zeros(size(ff));for nn=1:60 RR = RR + rr(nn)*exp(-j*2*pi*ff*nn/fs);endsemilogy(ff/1e3, abs(RR)) % the same as PLOT() except a logarithmic (base 10) scale for the Y-axis.xlabel('Frequency (KHz)')ylabel('|R(f)|')grid;pause% Time/freq responses to the 5 pulsesfor kk=1:5 subplot(5,2,2*kk-1) stem(1e6*tt((1:60)+(kk-1)*DeltaS), real(rr((1:60)+(kk-1)*DeltaS)),'b'); xlabel('Time (\mus)') title(sprintf('Impulse at t= %d ms',kk)) subplot(5,2,2*kk) RR = zeros(size(ff)); for nn=1:60 RR = RR + rr(nn+(kk-1)*DeltaS)*exp(-j*2*pi*ff*nn/fs); end semilogy(ff/1e3, abs(RR)) xlabel('Frequency (KHz)') ylabel('|R(f)|') grid;end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -