📄 music1.doc
字号:
clear all;
close all;
%*****Setting the system and the signal parameters**********************************
NumOfAntennas = 12;
NumOfSamples = 1000;
d_lamda = 0.5; % The ratio d/lamda
SNR=[20 20 25 25 20]; %The Interferer signals in db
Amp=[]; Amp = sqrt(2)*10.^(SNR/20); %Normalized amplitudes of the users
Theta_in_Deg=[0 22 -15 -20 -50]; % The DOA of the signals wrt the broadside(the normal to the array line)
Theta_in_Radians=Theta_in_Deg*pi/180;
Allowed_Noise_db=-40;
Noise_db=-40;
Noise=[];
Noise = sqrt(2)*10^(Noise_db/20)*exp(-j*1*pi*randn(NumOfAntennas,NumOfSamples) ); % Gaussian noise, variance = 1.0 for real and imag part, i.e. variance of noise = 2
Phi=[]; Phi = 2*pi*d_lamda*sin(Theta_in_Radians);
A=[];
for StrCounter=1:length(Theta_in_Deg) %Creating Steering vectors
A(:,StrCounter)=exp(-j*Phi(StrCounter)).^[0:NumOfAntennas-1]';
end
S=[];
for SignalCounter=1:length(Theta_in_Deg) %Creating the signals
S(SignalCounter,:) = Amp(SignalCounter)*exp(-j*1*pi*randn(1,NumOfSamples));
end
X = A*S + Noise;
%************************************************************************************
%Here the input samples are ready in the X(NumOfAntennas,NumOfSamples)
%************************************************************************************
%Creating the Covariance Matrix------------------------------------
clear CovMatrix V D ThetaAxis temp a;
CovMatrix(NumOfAntennas,NumOfAntennas)=0;
for counter1=1:NumOfSamples;
CovMatrix=CovMatrix+X(:,counter1)*X(:,counter1)';
end
CovMatrix=CovMatrix/NumOfSamples;
%------------------------------------------------------------------
%Getting the eigen values and the eigen vectors--------------------
[V,D]=eig(CovMatrix)
for counter=1:NumOfAntennas
if D(counter,counter)>sqrt(2)*10^(Allowed_Noise_db/20)
NumOfSignals=NumOfAntennas-counter+1;break
end
end
%------------------------------------------------------------------
%Creating P_MUSIC--------------------------------------------------
%Creating Vn
Vn=V(:,1:NumOfAntennas-NumOfSignals);
%-----------
ResolutionInDeg=0.1;
Theta_Axis_Deg=-90:ResolutionInDeg:90;
for counter2=1:180/ResolutionInDeg+1
%Creating (A) matrix for a given theta (counter2)
IntegersSet=0:NumOfAntennas-1;
IntegersSet=IntegersSet.';
ThetaAxis=2*pi*Theta_Axis_Deg(counter2);
temp=-i*2*pi*d_lamda*sin(ThetaAxis);
a=exp(temp*IntegersSet);
%------------------------------------------------
P_MUSIC(counter2)=(a'*a)/(a'*Vn*Vn'*a);
% P_MUSIC(counter2)=1/(a'*Vn*Vn'*a);
end
%------------------------------------------------------------------
figure
%semilogy(Theta_Axis_Deg , abs(P_MUSIC)); xlabel('Degrees'); ylabel('MUSIC spectrum') ; grid;
plot(Theta_Axis_Deg , abs(P_MUSIC)); xlabel('Degrees'); ylabel('MUSIC spectrum') ; grid;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -