1. 程式人生 > 其它 >【數字訊號調製】基於matlab多進位制數字振幅調製與解調(4APK)【含Matlab原始碼 997期】

【數字訊號調製】基於matlab多進位制數字振幅調製與解調(4APK)【含Matlab原始碼 997期】

一、簡介

1 4ASK訊號的原理



2 4ASK調製解調原理



二、原始碼


M=4;
d=1;
t=0:0.001:0.999;
a=randint(1,20,2);
i=1000;
for n=0:9
sym(n+1)=a(2*n+1)*2+a(2*n+2);
end
s=sym(ceil(10*t+0.01)).*cos(2*pi*100*t);
subplot(4,1,1);
plot(t,a(ceil((100*t+0.1)/5)));
title('二進位制訊號');
axis([0,1,-0.2,1.2]);
subplot(4,1,2);
plot(t,sym(ceil(10*t+0.01)));
title('四進位制訊號');
subplot(4,1,3);
plot(t,s)
title('4ASK訊號');
%相干解調 
at=s.*cos(2*pi*100*t);
at=at-mean(at);
[f,af]= T2F(t,at);%通過低通濾波器
[t,at]= lpf(f,af,80);
%      抽樣判決
for m=0:9;
    if at(1,m*100+50)>0.5;
       for j=m*100+1:(m+1)*100;
           at(1,j)=3;
       end
    else
        if at(1,m*100+50)>0;
           for j=m*100+1:(m+1)*100;
               at(1,j)=1;
           end
           %指令碼檔案F2T.m定義了函式F2T,計算訊號的反傅立葉變換。
function [t,st]=F2T(f,sf)
%This function calculate the time signal using ifft function for the input
%signal's spectrum
 df = f(2)-f(1);
Fmx = ( f(end)-f(1) +df);
dt = 1/Fmx;
N = length(sf);
T = dt*N;
%t=-T/2:dt:T/2-dt;
t = 0:dt:T-dt;
sff = fftshift(sf);
st = Fmx*ifft(sff);
function [t,st]=lpf(f,sf,B)
%This function filter an input data using a lowpass filter
%Inputs: f:  frequency samples
% sf: input data spectrum samples
% B:  lowpass's bandwidth with a rectangle lowpass
%Outputs:  t: time samples
% st: output data's time samples
df = f(2)-f(1);
T = 1/df;
hf = zeros(1,length(f));%全零矩陣
bf = [-floor( B/df ): floor( B/df )] + floor( length(f)/2 );
hf(bf)=1;
yf=hf.*sf;
[t,st]=F2T(f,yf);
st = real(st);

三、執行結果

四、備註

版本:2014a
完整程式碼或代寫加1564658423