%original signal
y=1*cos(2*pi*1000/3200000*(1:65536));
figure(1);
plot((1:65536)/3200000,y);
%delsig modulated signal
ntf=synthesizeNTF(4,64,1);
ds_y=simulateDSM(y,ntf);
figure(2);
plot((1:65536)/3200000,ds_y);
% %fft plot fft of modulated signal
% dsy_fft=fft(ds_y)/65536;
% figure(3);
% plot((1:65536)/65536*3200000,abs(dsy_fft));
% %modulated signal +1/2
% ds_y2=(ds_y+1)/2;
% dsy2_fft=fft(ds_y2)/65536;
% figure(4);
% plot((1:65536)/65536*3200000,abs(dsy2_fft));
%filter
Fpass=0.01;%16khz
Fstop=0.02;%32khz
Rpass=0.001;
Rstop=0.0005;
Hf=fdesign.lowpass(Fpass,Fstop,Rpass,Rstop,'linear');
Hd_multi=design(Hf,'multistage');
%filtered signal
y_fil=filter(Hd_multi,ds_y);
figure(5);
plot((1:65536)/3200000,y_fil(1:65536));
%%
% y_de=decimate(y_fil,64);
% figure(6);
% plot(y_de);
% y0=my_fil(ds_y);
b=[1,zeros(1,63),-1];
a=64*[1,-1];
y1=filter(b,a,ds_y);
y2=filter(b,a,y1);
y3=filter(b,a,y2);
y4=filter(b,a,y3);
y5=filter(b,a,y4);
figure(6);
plot(y5);