Sie sind auf Seite 1von 6

%% Initialization

clear, clf, clc


fc = 2000;
lambdac = 300/fc;
kc = 2*pi/lambdac;
cc = 3e8;
avPower = -20
%NFFT = 512;

%
%
%
%
%
%

Carrier frequency in MHz


Carrier wavelength in m
Propagation constant
Speed of light
Average power in dB of the MPCs
Number of points in FFT

% Frequency - Delay Pair


step_f = 0.01;
% Freq resolution in MHz
taumax = 1/(step_f.*1e6); % Max excess delay achieved in sec
% This is the Max Delay that can be measured with this
frequency sampling
% This should be compared with the expected max Delay as
calculated by the
% distance traveled by the MPCs.
BW = 5;
% RF bandwidth assumed in MHz
faxis = [fc-(BW/2):step_f:fc+(BW/2)];
% Freq axis in MHz
step_tau = taumax/(length(faxis)); % Delay resolution in sec
(= 1/BW)
tauaxis = [0:length(faxis)-1].*step_tau;
% Delay axis in
sec
% Time - Doppler Pair
V = 1.38;
% MS speed in m/sec
Nsamples = 512;
% Number of time/route samples
F = 10;
% Sampling rate: samples per wave length
Ds = lambdac/F;
% Sampling spacing in m
ts = Ds/V;
% Time sampling interval in sec
timeaxis = ts.*[0:Nsamples-1];
% Time axis in sec
fs = 1/ts;
% Sampling frequency in Hz
% This is also the Max Doppler that can be measured with
this time sampling
% This should be compared with the expected max Doppler as
calculated by
fm = V/lambdac
% Maximum Doppler shift in Hz
% It should be checked that fs >= fm, otherwise the max
Doppler cannot be
% measured by the simulation
step_Dop = fs/Nsamples; % Doppler resolution in Hz
Doppleraxis = [-(Nsamples-1)*step_Dop/2:step_Dop:(Nsamples1)*step_Dop/2]; % Doppler axis in Hz

%Doppleraxis = ([0:NFFT-1]-NFFT/2)*(fs/(NFFT-1)); % Doppler


axis in Hz
%% Positions
% Plot BS Position
=====================================================
BSx = 0;
BSy = 0;

% location of transmitter (BS) x-coordinate


% location of transmitter (BS) y-coordinate

plot(BSx,BSy,'k^'), hold on
% Plot MS Positions
=====================================================
dMS0 = 100;
% initial distance of receiver (MS) from BS in
meters
thetaMS0 = 90; % angle of the initial position of the MS
w.r.t. x-axis
Vangle = 270; % the angle of the velocity vector w.r.t. xaxis and with MS
% at center of the coordinate system
MSx = zeros(Nsamples);
MSy = zeros(Nsamples);
MS0x = dMS0*cosd(thetaMS0); % initial x-coordinate of MS
MS0y = dMS0*sind(thetaMS0); % initial y-coordinate of MS
MSx = MS0x + V.*timeaxis*cosd(Vangle);
MSy = MS0y + V.*timeaxis*sind(Vangle);
plot(MSx,MSy,'k','LineWidth',5)
MINx = min(min(BSx,MSx))-1000;
MAXx = max(max(BSx,MSx))+1000;
MINy = min(min(BSy,MSy))-1000;
MAXy = max(max(BSy,MSy))+1000;
axis([MINx MAXx MINy MAXy])
plot([0 0],[MINy MAXy], 'k:')
plot([MINx MAXx],[0 0], 'k:')
xlabel('Distance (m)')
ylabel('Distance (m)')

% Positions of Scatterers
================================================
SCx = [0];
SCy = [500];
%a = [1; 0.5];

% x-coordinate of scatterers
% y-coordinate of scatterers
% magnitude of echoes

NSC = length(SCx);
plot(SCx,SCy,'+');
%% Calculations needed for the Frequency Response
% Calculate Distance from BS to SC to MS
distBSSC = sqrt((BSx-SCx).^2+(BSy-SCy).^2);
distBSSCext = repmat(distBSSC,1,Nsamples);
distSCMS = zeros(NSC,Nsamples);
for ii = 1:Nsamples
distSCMS(:,ii) = sqrt((SCx-MSx(ii)).^2+(SCyMSy(ii)).^2);
end
distBSSCMS = distBSSCext+distSCMS;
% Calculate new coordinates for angle of Doppler
========================
% The coordinates of SC w.r.t. the MS0 position
SCx_new = SCx - MS0x;
SCy_new = SCy - MS0y;
SC_new = [SCx_new SCy_new];
% The coordinates of final MS position w.r.t. the MS0
position
MSx_end = MSx(Nsamples) - MS0x;
MSy_end = MSy(Nsamples) - MS0y;
MS_end = [MSx_end MSy_end];
% Calculate the angle in Doppler equation for the link from
the SC to MS
for k3 =1 :NSC
alpha(k3) = acosd(dot(SC_new(k3,:),MS_end)/
(norm(SC_new(k3,:))*norm(MS_end)));
end

% Calculate the angle in Doppler equation for the link from


the BS to MS
BSx_new = -MS0x;
BSy_new = -MS0y;
BS_new = [BSx_new BSy_new];
angleV_BSMS = acosd(dot(BS_new,MS_end)/
(norm(BS_new)*norm(MS_end)))
% Calculate power of the MPCs
% Assume that the RCS of all scatterers is 1
a=(dMS0./sqrt(distBSSC(:))).*(dMS0./sqrt(distSCMS(:,1)));
DeltaPower=avPower-10*log10(sum(a.^2));
deltaa=10.^(DeltaPower/20);
% to normalize power
a=deltaa*a;
%% Caclulate the Frequency Response
FreqResp=zeros(Nsamples,length(faxis));
for k1=1:Nsamples
% for all route points
for k2=1:length(faxis)
% for all frequencies
for k3=1:NSC
% for all scatterers
wl2=300/faxis(k2);
w=300/(faxis(k2)-fc);
FreqResp(k1,k2)=[FreqResp(k1,k2)...
+
a(k3)*exp(j*(2*pi/wl2)*V*timeaxis(k1)*cos(alpha(k3)))...
* exp(-j*(2*pi/w)*distBSSCMS(k3,k1))];
end
end
end
%% Calculate the Channel Impulse Response through IFFT
ImpResp = zeros(Nsamples,length(faxis));
for k4 = 1:Nsamples
ImpResp(k4,:) = ifft(FreqResp(k4,:));
end
%% Prepare Plots
%
%
%
%
%

figure;mesh(faxis,timeaxis,abs(FreqResp))
ylabel('Time (s)')
xlabel('Frequency (MHz)')
zlabel('Level (l.u.)')
title('Time.varying frequency response')

figure;mesh(faxis,timeaxis,20*log10(abs(FreqResp)))
ylabel('Time (s)')
xlabel('Frequency (MHz)')
zlabel('Level (dB)')
title('Time-varying frequency response')
figure;plot(timeaxis,20*log10(abs(FreqResp(:,1))),'k')
xlabel('time (s)')
ylabel('level (dB)')
title('Complex envelope magnitude central frequency')
figure;plot(faxis,20*log10(abs(FreqResp(1,:))),'k')
xlabel('frequency (MHz)')
ylabel('level (dB)')
title('Frequency response for first route point')
figure;plot(faxis,angle(FreqResp(1,:)),'k')
xlabel('frequency (MHz)')
ylabel('phase (Rad)')
title('Frequency response for the first route point')
figure;mesh(tauaxis,MSx,abs(ImpResp))
xlabel('delay (s)')
ylabel('route point (m)')
zlabel('level (l.u.)')
title('Impulse response variable with time')
figure;plot(tauaxis,abs(ImpResp(1,:)),'k')
xlabel('delay (s)')
ylabel('level (l.u.)')
title('Impulse response for the first route point')
%===========================================================
============
taumax
step_tau
distBSSCMS(:,1)/cc
auxz=size(ImpResp);
%ScatMat=zeros(NFFT,auxz(2));
ScatMat=zeros(auxz(1),auxz(2));
for kk=1:auxz(2)
% for all delay bins
ScatMat(:,kk)=fftshift(abs(fft(ImpResp(:,kk))).^2);
%ScatMat(:,kk)=fftshift(abs(fft(ImpResp(:,kk),NFFT)).^2);

end
ScatMatdB=10*log10(ScatMat);
Floor=-50;
[ww,zz]=find(ScatMatdB==-inf);
ScatMatdB(ww,zz)=Floor;
figure;surf(tauaxis,Doppleraxis,ScatMatdB)
shading interp
colormap(jet)
ylabel('Doppler (Hz)')
xlabel('Delay (sec)')
zlabel('Level (dB)')
title('Scattering Function')

Das könnte Ihnen auch gefallen