From 8b347811bd2dff0ace0fb016efef32cefa7e7678 Mon Sep 17 00:00:00 2001 From: David Protzman Date: Sat, 23 Apr 2022 00:47:59 -0400 Subject: [PATCH] Split the creation of the ZC sequence out from creating time domain --- matlab/updated_scripts/create_zc.m | 8 ++++---- matlab/updated_scripts/create_zc_seq.m | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 matlab/updated_scripts/create_zc_seq.m diff --git a/matlab/updated_scripts/create_zc.m b/matlab/updated_scripts/create_zc.m index 25a1625..18fa7a6 100644 --- a/matlab/updated_scripts/create_zc.m +++ b/matlab/updated_scripts/create_zc.m @@ -21,9 +21,7 @@ function [samples] = create_zc(fft_size, symbol_index) root = 147; end - % Would use MATLAB's zadoffChuSeq function, but Octave doesn't have that - % The logic below was tested against the MATLAB function - zc = reshape(exp(-1j * pi * root * (0:600) .* (1:601) / 601), [], 1); + zc = reshape(create_zc_seq(fft_size, root), [], 1); % Figure out how many guard carriers there should be (purposely ignoring DC here) guard_carriers = fft_size - 600; @@ -39,7 +37,9 @@ function [samples] = create_zc(fft_size, symbol_index) % Null out the DC carrier samples_freq(fft_size/2) = 0; + + samples_freq % Convert to time domain making sure to flip the spectrum left to right first - samples = ifft(fftshift(samples_freq)); + samples = ifft(fftshift(samples_freq)) / fft_size; end diff --git a/matlab/updated_scripts/create_zc_seq.m b/matlab/updated_scripts/create_zc_seq.m new file mode 100644 index 0000000..a643ae6 --- /dev/null +++ b/matlab/updated_scripts/create_zc_seq.m @@ -0,0 +1,8 @@ +function [zc_seq] = create_zc_seq(fft_size, root) + assert(log2(fft_size) == round(log2(fft_size)), "Invalid FFT size. Must be power of 2"); + + % Would use MATLAB's zadoffChuSeq function, but Octave doesn't have that + % The logic below was tested against the MATLAB function + zc_seq = exp(-1j * pi * root * (0:600) .* (1:601) / 601); +end +