diff --git a/matlab/updated_scripts/calculate_channel.m b/matlab/updated_scripts/calculate_channel.m index 8665d91..e39fc37 100644 --- a/matlab/updated_scripts/calculate_channel.m +++ b/matlab/updated_scripts/calculate_channel.m @@ -1,15 +1,17 @@ -% Calculate channel taps based on the 4th OFDM symbol (first ZC sequence) +% Calculate channel taps based on the 4th or 6th OFDM symbol (both are ZC sequences) % % There is almost certainly a better way to do this, but this gets the job done % -% @param zc_seq Frequency domain ZC sequence from OFDM symbol number 4 (all FFT bins, no cyclic prefix) +% @param zc_seq Frequency domain ZC sequence from OFDM symbol number 4 or 6 (all FFT bins, no cyclic prefix) % @param sample_rate Sample rate (in Hz) of `zc_seq` -% @return taps Result of dividing `zc_seq` into a golden reference copy of the first ZC sequence -function [taps] = calculate_channel(zc_seq, sample_rate) +% @param symbol_idx Which symbol (must be 4 or 6) is in the `zc_seq` vector +% @return taps Result of dividing `zc_seq` into a golden reference copy of the selected ZC sequence +function [taps] = calculate_channel(zc_seq, sample_rate, symbol_idx) + assert(symbol_idx == 4 || symbol_idx == 6, "Symbol index must be 4 or 6"); fft_size = get_fft_size(sample_rate); % The golden reference needs to be in the frequency domain - gold_seq = fftshift(fft(reshape(create_zc(fft_size, 4), size(zc_seq)))); + gold_seq = fftshift(fft(reshape(create_zc(fft_size, symbol_idx), size(zc_seq)))); % figure(400); % subplot(1, 2, 1); diff --git a/matlab/updated_scripts/process_file.m b/matlab/updated_scripts/process_file.m index aae64d2..b2a51a8 100644 --- a/matlab/updated_scripts/process_file.m +++ b/matlab/updated_scripts/process_file.m @@ -101,7 +101,7 @@ for burst_idx=1:size(bursts, 1) [time_domain_symbols, freq_domain_symbols] = extract_ofdm_symbol_samples(burst, file_sample_rate); % Calculate the channel based on the first ZC sequence which is in OFDM symbol #4 - channel = calculate_channel(freq_domain_symbols(4,:), file_sample_rate); + channel = calculate_channel(freq_domain_symbols(4,:), file_sample_rate, 4); % Place to store the demodulated bits bits = zeros(9, 1200);