92 lines
3.2 KiB
Matlab
92 lines
3.2 KiB
Matlab
function T = rxadcfs(fl, fh, mts)
|
|
%Use this function to find allowable frequencies
|
|
%
|
|
|
|
%%
|
|
% SYNTAX: T = rxadcfs(fl, fh, mts(optional));
|
|
%
|
|
% DESCRIPTION: Apply the bandpass sampling theorem and Nyquist sampling theorem
|
|
% to calculate all good sampling rates to avoid spectral overlap.
|
|
%
|
|
% INPUT: - fl (real double)
|
|
% Lowest frequency of the real-valued bandpass signal. Unit =
|
|
% Hz.
|
|
%
|
|
% - fh (real double)
|
|
% Highest frequency of the real-valued bandpass signal. Unit =
|
|
% Hz.
|
|
% - mts set to 1 to limit results for use with multi tile
|
|
% sync enables
|
|
%
|
|
% OUTPUT: - T (table)
|
|
% Table of all good sampling rates. Valid columns are:
|
|
%
|
|
% T.theory = either 'Bandpass' (for Bandpass sampling theorem)
|
|
% or 'Nyquist' (for Nyquist sampling theorem).
|
|
%
|
|
% T.n = n is variable in the Bandpass sampling theorem and n
|
|
% is an integer. n is NaN for Nyquist sampling theorem.
|
|
%
|
|
% T.Fs_LO_Hz = lowest sampling rate in Hz.
|
|
%
|
|
% T.Fs_HI_Hz = highest sampling rate in Hz.
|
|
%
|
|
|
|
|
|
%% Initialize s.
|
|
s = struct;
|
|
s.Theory = categorical({});
|
|
s.n = [];
|
|
s.Fs_LO_Hz = [];
|
|
s.Fs_HI_Hz = [];
|
|
|
|
if (nargin == 3) && mts == 1
|
|
mtsList = [737.28, 1474.56, 1966.08, 2457.6, 2949.12, 3072, 3932.16, 4669.44, 4915.2, 5898.24, 6144];
|
|
%% Bandpass Sampling Theorem. Calculate all good sampling rates.
|
|
for n = floor(fh / (fh - fl)) : -1 : 2
|
|
% look for valid mts frequencies only if selected
|
|
for mtsIndex = 1:length(mtsList)
|
|
if mtsList(mtsIndex)*1e6 >= 2 * fh / n && mtsList(mtsIndex)*1e6 <= 2 * fl / (n - 1)
|
|
s.Theory(end+1, 1) = 'Bandpass';
|
|
s.n(end+1, 1) = n;
|
|
s.Fs_LO_Hz(end+1, 1) = mtsList(mtsIndex);%2 * fh / n;
|
|
s.Fs_HI_Hz(end+1, 1) = mtsList(mtsIndex);%2 * fl / (n - 1);
|
|
end %if mtsList...
|
|
end %for mtsIndex...
|
|
end %for n = floor...
|
|
else
|
|
%% Bandpass Sampling Theorem. Calculate all good sampling rates.
|
|
for n = floor(fh / (fh - fl)) : -1 : 2
|
|
s.Theory(end+1, 1) = 'Bandpass';
|
|
s.n(end+1, 1) = n;
|
|
s.Fs_LO_Hz(end+1, 1) = 2 * fh / n;
|
|
s.Fs_HI_Hz(end+1, 1) = 2 * fl / (n - 1);
|
|
end
|
|
end
|
|
|
|
if (nargin == 3) && mts == 1
|
|
mtsList = [737.28, 1474.56, 1966.08, 2457.6, 2949.12, 3072, 3932.16, 4669.44, 4915.2, 5898.24, 6144];
|
|
%% Nyquist Sampling Theorem. Calculate all good sampling rates.
|
|
for mtsIndex = 1:length(mtsList)
|
|
if mtsList(mtsIndex)*1e6 >= 2 * fh && mtsList(mtsIndex)*1e6 <= inf
|
|
s.Theory(end+1, 1) = 'Nyquist';
|
|
s.n(end+1, 1) = NaN;
|
|
s.Fs_LO_Hz(end+1, 1) = mtsList(mtsIndex);%2 * fh;
|
|
s.Fs_HI_Hz(end+1, 1) = mtsList(mtsIndex);%Inf;
|
|
end
|
|
end
|
|
else
|
|
%% Nyquist Sampling Theorem. Calculate all good sampling rates.
|
|
s.Theory(end+1, 1) = 'Nyquist';
|
|
s.n(end+1, 1) = NaN;
|
|
s.Fs_LO_Hz(end+1, 1) = 2 * fh;
|
|
s.Fs_HI_Hz(end+1, 1) = Inf;
|
|
end
|
|
|
|
%% Convert s to T.
|
|
T = struct2table(s);
|
|
|
|
|
|
end
|
|
|