📄 tb_fir_compiler.m
字号:
%---------------------------------------------------------------------------------------------------------
%
% THIS IS A WIZARD GENERATED FILE. DO NOT EDIT THIS FILE!
%
%---------------------------------------------------------------------------------------------------------
% Test Bench For fir_compiler_mlab Function
clear
sti_type = ['imp'];
[sx,sy]= size(sti_type);
num_ch = 1;
for j = 1:sx
for i = 1: num_ch
str = num2str(i);
if(num_ch >1)
file_name =['fir_compiler_data_in_ch',str];
else
file_name =['fir_compiler_data_in'];
end
if sx > 1
file_name = [file_name,'_',sti_type(j,:)];
end
file_name = [file_name,'.txt', ];
infile = fopen (file_name, 'r');
%fprintf( '%s\n', file_name);
data = fscanf(infile, '%d' );
fclose(infile);
output = fir_compiler_mlab(data');
%Generate Output
if(num_ch >1)
file_name =['fir_compiler_mlab_result_ch',str];
else
file_name = ['fir_compiler_mlab_result'];
end
if sx > 1
file_name = [file_name,'_',sti_type(j,:)];
end
file_name = [file_name,'.txt', ];
outfile1 = fopen(file_name,'w');
fprintf(outfile1, '%20.0f\n', output);
fclose(outfile1);
if i == 1
%Time Domain Response Plotting
figure(1);
sz = size(output);
max_x = max(sz);
xline = linspace (0, max_x - 1, max_x);
plot (xline, output,'r');
title_string = 'Time Response Display';
if num_ch > 1
title_string = [title_string,' Channel 1'];
end
if j == 1
title_string = [title_string,' - Impluse'];
elseif j == 2
title_string = [title_string,' - Step'];
elseif j == 3
title_string = [title_string,' - Random'];
end
title (title_string);
grid on;
zoom on;
% Frequency Domain Plotting
to_plot = output;
figure(2);
freqdat = fft(to_plot);
absdat = abs(freqdat);
maxdat = max (absdat);
logdat = 20*log10(absdat);
sz = size(to_plot);
numpts = max(sz);
freq_res = 1/numpts;
xline = linspace (0, ( (1/2)- freq_res ), round(numpts/2) );
plot (xline, logdat(1: round(numpts/2) ), 'b');
title_string = 'Frequency Response Display';
if num_ch > 1
title_string = [title_string,' Channel 1'];
end
if j == 1
title_string = [title_string,' - Impluse'];
elseif j == 2
title_string = [title_string,' - Step'];
elseif j == 3
title_string = [title_string,' - Random'];
end
title (title_string);
grid on;
zoom on;
xlabel ('Frequency');
ylabel ('Magnitude - dB');
end
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -