📄 fir_data.m
字号:
% fir_data.m
% Script for generating data to test FIR functions in in the VisualDSP Blackfin tools
%
% Output files (in VisualDSP buffer initialization format):
% 1) 'in.dat' - the input data
% 2) 'coefs.dat' - the FIR taps
% 3) 'out.ans' - the filter output computed by Matlab
%
% (tl)
VEC_SIZE = 256; % length of the input buffer
NUM_TAPS = 8; % number of filter coefficients
Fs = 10e3; % sampling frequency
% vector data: sum of a sine wave at 1 Khz and a sine wave at 4 kHz
t = [0:1:(VEC_SIZE-1)]./Fs;
in = (sin(1e3*(2*pi*t)) + sin(4e3*(2*pi*t)))/2;
% LPF with Fc at 2.5 kHz
coefs = fir1(NUM_TAPS-1, 2.5e3/(Fs/2));
out = conv(in, coefs); % convolve the input with the filter
% plot the input and save it to file 'in.dat'
figure(1);
subplot(2,1,1);
plot(t, in);
title('Input');
xlabel('time');
subplot(2,1,2);
plot(abs(fft(in)));
xlabel('frequency');
save_fr16_init(float_to_fr16(in'), 'in.dat');
% plot the filter coefficients and save them to file 'coefs.dat'
figure(2);
subplot(2,1,1);
plot(coefs);
title('Coefficients');
xlabel('time');
subplot(2,1,2);
plot(abs(fft(coefs)));
xlabel('frequency');
save_fr16_init(float_to_fr16(coefs'), 'coefs.dat');
% plot the output and save them to file 'out.ans'
figure(3);
subplot(2,1,1);
plot(out);
title('Output');
xlabel('time');
subplot(2,1,2);
plot(abs(fft(out)));
xlabel('frequency');
save_fr16_init(float_to_fr16(out'), 'out.ans');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -