|
转贴一份BPSK程序(取自研学论坛):
% Simulation program to realize BPSK transmission system
%
% Programmed by snowflier,
%
%******************** basic information of the signal **********************
sr=100.0; % Symbol rate
ml=1; % Number of modulation levels(bpsk)
br=sr.*ml; % Bit rate (=symbol rate in this case)
nd = 10; % Number of symbols that simulates in each loop
%ebn0=3; % Eb/N0
IPOINT=100; % Number of oversamples
T=nd/sr;
fc=10/T;
%******************** Data generation ********************************
data=rand(1,nd)>0.5; % rand: built in function
data=data.*2-1;
[data1]=oversamp(data,nd,IPOINT);
%******************* Filter initialization ********************
irfn=21; % Number of filter taps
alfs=0.5; % Rolloff factor
[xh] = hrollfcoef(irfn,IPOINT,sr,alfs,1); %Transmitter filter coefficients
%[xh2] = hrollfcoef(irfn,IPOINT,sr,alfs,0); %Receiver filter coefficients
%data=conv(data,xh);
%********************modulation********************************
delta_T=T/length(data1);
t=delta_T:delta_T:T;
b=zeros(1,length(data1));
bpsk=zeros(1,length(data1));
for i=1:100:length(data1)
%b=cos(2*pi*fc*t+pi*data1(i));
b=data1(i)*exp(j*2*pi*fc*t);
bpsk(i:i+99)=b(i:i+99);
end
f=-0.5/delta_T:1/(delta_T*(length(data1)-1)):0.5/delta_T;
BPSK=abs(fft(bpsk));
subplot(211);
plot(real(bpsk));
subplot(212);
plot(f,fftshift(BPSK));
c=cwt(bpsk,1:40,'Haar');x=zeros(1,length(abs(c(2,:))));x=abs(c(2,:));figure,plot(x) |
|