?? init.m
字號:
simtime =500;
Tsamp1 = 1/125E6;
Tsamp2 = 1/250E6;
coeff = [-524,0,459,0,-236,0,9,0,-20,0,41,0,-76,0,133,0,-221,0,354,0,-545,0,815,0,-1190,0,1705,0,-2420,0,3437,0,-4978,0,7614,0,-13457,0,41569,65536,41569,0,-13457,0,7614,0,-4978,0,3437,0,-2420,0,1705,0,-1190,0,815,0,-545,0,354,0,-221,0,133,0,-76,0,41,0,-20,0,9,0,-236,0,459,0,-524;]
% extract the larger filter phase and accumulate its DC gain
acc = 0;
for i = 1:40
hb1(i) = coeff(((i-1)*2)+1);
acc = acc + coeff(((i-1)*2)+1);
end;
% set the simple phase single tap to match the DC gain of the larger phase
hb2 = acc;
% ********** use below for a crude coeff set
%hb2 = 1;
%for i = 1:40
% hb1(i) = 0;
%end;
%hb1(20) = 0.5;
%hb1(21) = 0.5;
% Generate impulse and chirp test data
t = 1:500;
chirp_input = chirp(t,0,500,0.5) * ((2^16-1));
y1=zeros(500,1)';
y2=zeros(40,1)';
impulsein=[y2 1 y1];
chirpin=[y2 chirp_input];
impulse_in = zeros(simtime,2);
chirp_in = zeros(simtime,2);
for i = 1:simtime
impulse_in(i, 1) = i*Tsamp1;
impulse_in(i, 2) = impulsein(i);
chirp_in(i, 1) = i*Tsamp1;
chirp_in(i, 2) = chirpin(i);
end
y = chirpin;
% run the fir over the test data
for i = 1:460
% Do the simple phase of the filter
accph1 = y(i+21) * hb2;
% Do the larger the phase of the filter
accph2 = 0;
for j = 1:40
mult = y(i+j) * hb1(j);
accph2 = accph2 + mult;
end;
% 250MHz Mux
filt((2*i)) = accph2;
filt((2*i)+1) = accph1;
end;
filt_chirp = filt';
figure(1);
subplot(2,1,1);
plot(y);
title('Chirp input data');
subplot(2,1,2);
plot(filt);
title('Filter output - Chirp');
y=impulsein;
% run the fir over the test data
for i = 1:460
% Do the simple phase of the filter
accph1 = y(i+21) * hb2;
% Do the larger the phase of the filter
accph2 = 0;
for j = 1:40
mult = y(i+j) * hb1(j);
accph2 = accph2 + mult;
end;
% 250MHz Mux
filt((2*i)) = accph2;
filt((2*i)+1) = accph1;
end;
filt_impulse = filt';
figure(2);
subplot(2,1,1);
plot(y);
title('Impulse input data');
subplot(2,1,2);
plot(filt);
title('Filter output - Impulse');
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -