how to do sampling for the output of matched filter?
6 views (last 30 days)
Show older comments
clc;
clear all;
close all;
tp=2.2676*10^-3;
Ts=22.6757*10^-6;
fc=4000;
Tc=(1/fc);
fs=44100;
n=0:Ts:1000;
fp=(1/tp);
w=2*pi*fp;
p=sin(w*n*Ts);
p(find(p<0))=0;
figure(1)
subplot(3,1,1);
plot(n,p);
data = randi([0,1],1,1000);
a=[];
for k=1:2:1000
if data(k)==0 && data(k+1)==0
a=[a 1];
elseif data(k)==0 && data(k+1)==1
a=[a i];
elseif data(k)==1 && data(k+1)==0
a=[a -1];
elseif data(k)==1 && data(k+1)==1
a=[a -i];
end
end
figure(2)
subplot(3,1,2);
y_s=conv(a,p);
Trm=min(numel(n),numel(y_s))
n=n(1:Trm);
y_s=y_s(1:Trm);
plot (n,real(y_s), '-',n,imag(y_s), '--');
%% modulation of 2 signals
figure(3)
subplot(3,1,3);
in_phase_carrier=cos(2*pi*fc*n*Ts);
q_phase_carrier=sin(2*pi*fc*n*Ts);
y_m=real(y_s).*in_phase_carrier+imag(y_s).*q_phase_carrier;
plot (n,real(y_m), '-');
subplot(3,2,3);
plot(n,imag(y_m), '--');
noise=sqrt(.25)*rand(1,length(y_m));
%power of signal
%pav=sum(y_m.^2)/length(y_m);
%et=sum(y_m.^2)/fs;
% Es=((y_m).^2);
% EsNo=((noise).^2);
% Eb=Es.*110/2;
% snr=sqrEb./EsNo;
%
% snrdb=snr(y_m,noise);
%snrdb=1:20;
% snrlin=10.^(snrdb./10);
%eb=sum(y_m.^2)/length(y_m);
% No=Es/snrlin;
% multipath channel
u=0.00022676;
g=5/60;
n1=(u-n);
in_phase_carrier_rec=cos(2*pi*fc*n1*Ts);
q_phase_carrier_rec=sin(2*pi*fc*n1*Ts);
y_mn1=(real(y_s).*in_phase_carrier_rec)+(imag(y_s).*q_phase_carrier_rec);
figure(4)
subplot(4,1,4);
r = (sqrt((1-g)^2))*y_m+y_mn1*g+noise;
plot(n,r);
%% demodulation of signal
subplot(4,2,4);
r_dm_in=real(r).*in_phase_carrier;
plot(n,r_dm_in,'-');
r_dm_out=imag(r).*q_phase_carrier;
plot(n,r_dm_out,'--');
%% fft of signal
L=length(r_dm_in);
NEFT=2^nextpow2(L);
r_dm_in_fft=abs(fft(r_dm_in,NEFT));
freq = fs/2*linspace(0,1000,NEFT/2+1);
subplot(4,3,4);
plot(freq,r_dm_in_fft(1:length(freq)),"LineStyle","--");
%% match filter
figure(5)
o=5;
b=438;
a=442
subplot(5,1,5);
r_filt=filter(b,a,r_dm_in);
plot(n,r_filt);
subplot(5,2,5);
r_filt_img=filter(b,a,r_dm_out);
plot(n,r_filt_img);
c = xcorr(r_dm_in,n);
plot(c);
%snrdb=1:1:20;
%snrlin=10.^(snrdb/10);
%% sampling
%sampling in phase
how to proceed with sampling??
0 Comments
Answers (0)
See Also
Categories
Find more on Digital Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!