⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bpsk_v1.m

📁 通过循环谱分析信号的方式达到对各种数字通信信号的调治识别,这是一种很好的方式,具体实现算法有FAM,SSCA,SCOUT等
💻 M
字号:
%数据设置部分
Rb=2;     %码源速率
Ts=1/Rb;   %码源间隔
L=2^6;     %单位时间内信号抽样点数
num=16;   %一个段落中码源个数
N=num*L;  %一个段落内总的抽样点数 (1024)

f0=16;   %载波频率
dt=Ts/L;  %抽样时间间隔
df=1/(dt*N);   %频率间隔
Bs=df*N/2;   %带宽
fs=Bs*2;
f=df/2-Bs:df:Bs;   %抽样频率
t=dt/2:dt:num*Ts;  %抽样时间  t= 1/(4*64) : 1/(2*64) : 8;

a=sign(randn(1,num)); %码源序列 generate the initial signal (length is 16)

%%%%%%%%%%%% BPSK调制信号产生
%通过基带成型滤波器后的信号   function ?????????????????????????????????
for rr=1:num
    I((rr-1)*L+1:rr*L)=a(rr);  % number of I is 1024 .extend the length of signal 'a' to 64 times length.
end

%最终调制信号 the signal modulated by BPSK carrier
s=I.*cos(2*pi*f0*t);  % the number of 't'and 's' are the same.(1024)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% begin to FFT
M=2;
Fs=fs;
N = (M*Fs)/df;  % the new value of 'N'is 2 times the value of old 'N'. (2048)
N = pow2 (nextpow2(N)); % windowing record for FFT (2048)   % NEXTPOW2(N) returns the first P such that 2^P >= abs(N)
                                                      % X = POW2(Y) for each element of Y is 2 raised to the power Y
%设置FFT点数为1024
X = fft(s,N);   % fft of the truncated(被删节的) (or zero padded) time series (2048 columns)
X = fftshift(X);% shift components of fft  (2048 columns)
Xc = conj(X);                 % precompute the complex conjugate(复共轭) vector (2048 columns)

S = zeros (N,N);              % size of the Spectral Correlation Density matrix
f = zeros (N,N);              % size of the frequency matrix;
alfa = zeros (N,N);           % size of the cycle frequency matrix
F = Fs/(2*N);                 % precompute(预先计算的) constants -  F = Fs/(2*N);     
G = Fs/N;                     % precompute constants -  G = Fs/N;  
m = -M/2+1:M/2;               % set frequency smoothing window index  % m(0)=0,m(1)=1.

for k = 1:N                                % fix k    (2048 columns)
    % computes vectors of f and alfa,
    % store frequency and cycle frequency data for given k.
    k1 = 1:N;
    f(k,k1) = F*(k+k1-1) - Fs/2;          % Computes f values and shift them to center in zero (f = (K+L)/2N) [1]
    alfa(k,k1) = G*(k-k1 + N-1) - Fs;       % Computes alfa values and shift them to center in zero (alfa = (K-L)/N) [1]
       for k1 = 1:N                          %fix k1 = J
            %calculate X(K+m) & conj (X(J+m)) for arguments of X(1:N) only
           B = max(1-k, 1-k1);          % Largest min of 1 <= (K+m)| (J+m) <= N
           A = min (N-k, N-k1);         % Smallest max of 1 <= (K+m)| (J+m) <= N
           n = m((m<=A) & (m>=B));      % fix the index out of range problem by truncating the window.  % m(0)=0,m(1)=1.
             if isempty(n)
                S(k,k1) = 0;
             else
                p = k+n; q = k1+n;
                Y = X(p).*Xc(q);  
                S(k,k1) = sum(Y);  %  the power spetral Correlation destiny function 
             end
       end
end
% haha=length(sign([real(Y)]))
S = abs(S./max(max(S)));% normalize output matrix
% figure(1);
% contour (alfa, f, S); grid;
figure(1);
mesh(alfa, f, S); % 'alfa'is cycle frequency.'f'is frequency.'S'is Spetral Correlation Density Function.
ylabel('Frequency (Hz)');xlabel('Cycle frequency (Hz)'); 
title('BPSK循环谱三维图');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -