clc ;
close all ;
clear all ;
fs = 100* 10^ 6 ;
fc1 = 1 * 10^6 ;
fc2 = 16 * 10^6 ;
t = 0 : 1/fs : 256/fs ;
y = cos (2 * pi * fc1 * t ) + cos (2 * pi * fc2 * t ) ;
cof = [-0.000695676179413289,-0.00212059279559494,-0.00437800207625060,-0.00670558750976843,-0.00739695931790013,-0.00393949465113584,0.00632167179169658,0.0251365935247956,0.0522801254271389,0.0849413081084903,0.117956285172739,0.144967603065588,0.160193277712091,0.160193277712091,0.144967603065588,0.117956285172739,0.0849413081084903,0.0522801254271389,0.0251365935247956,0.00632167179169658,-0.00393949465113584,-0.00739695931790013,-0.00670558750976843,-0.00437800207625060,-0.00212059279559494,-0.000695676179413289;]
figure(1) ;
subplot(2,1,1) ;
plot(t,y) ;
yy = conv(y,cof) ;
yy1 = filter(cof,1,y) ;
subplot(2,1,2) ;
plot(yy1) ;
m_length = length(cof) ;
reg_data = zeros(length(t)-1 , 1) ;
yy = zeros(m_length,1) ;
for i = 1 : length(t)
for m = 1 : m_length
if (m == 1)
ys(i) = y(i) * cof(m) ;
else
ys(i) = ys(i) + yy(m-1) * cof(m) ;
end
end
for mm = m_length-1 :-1 : 1 %移位
if (mm == 1)
yy(mm) = y(i) ;
else
yy(mm) = yy(mm-1) ;
end
end
% yyy(i+1) = y(i) ;
end
figure(2) ;
plot(ys)