No BSD License  

Highlights from
Tektronix RSA3000A/B User-Defined Filter Converter

Tektronix RSA3000A/B User-Defined Filter Converter

by

 

22 Jun 2008 (Updated )

Convert MATLAB filter coefficient files to a RSA3000-compatable format

m2csvfilt(strFileName)
%% m2csvfilt: Convert Matlab .m filter coefficient file to a CSV file 
%             that can be used by the RSA3000.
%
%  Inputs: 
%       strFileName: 
%           File to be read, with path but without extension
%
%  Outputs:
%       None
%
%  Example: 
%       m2csvfilt('C:\matlab\my_filter');
%           Loads "C:\matlab\my_filter.m", converts the filter data,
%           and writes the file as "C:\matlab\my_filter.csv"
%
%
function m2csvfilt(strFileName)

nRSAOversampling = 8;

%% Assume that the .m file was created.
A = eval(strFileName);
mCoeffs = A.Numerator;


%% Open the output file
fid = fopen([strFileName '.csv'], 'w');
if -1 == fid
    error([strFileName '.csv could not be opened for writing']);
end

%% Write the header to the outout
fprintf(fid, [num2str(nRSAOversampling) '\n']);

%% Write the coefficients to the output
%  For now we're only going to deal with real and complex
%  filters.
nCoeffSize = size(mCoeffs);
for n = 1:nCoeffSize(2)
    strLine = [num2str(real(mCoeffs(n)), 20) ', ' num2str(imag(mCoeffs(n)), 20)];
    fprintf(fid, [strLine '\n']);
end

%% Close the output file
fclose(fid);



end

Contact us