From 43949eda91bf5f4bd0662a6e6d63c3a32979a240 Mon Sep 17 00:00:00 2001 From: David Protzman Date: Mon, 18 Apr 2022 23:51:48 -0400 Subject: [PATCH] Removed use of mustBeMember since it doesn't exist in Octave --- matlab/updated_scripts/generate_scrambler_seq.m | 2 +- matlab/updated_scripts/must_be_member.m | 9 +++++++++ matlab/updated_scripts/process_file.m | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 matlab/updated_scripts/must_be_member.m diff --git a/matlab/updated_scripts/generate_scrambler_seq.m b/matlab/updated_scripts/generate_scrambler_seq.m index 6d44d24..97a1b01 100644 --- a/matlab/updated_scripts/generate_scrambler_seq.m +++ b/matlab/updated_scripts/generate_scrambler_seq.m @@ -8,7 +8,7 @@ function [bits] = generate_scrambler_seq(num_bits, x2_init) assert(isrow(x2_init), "X2 initial value must be a row vector"); assert(length(x2_init) == 31, "The X2 initial value must be 31 bits"); - mustBeMember(x2_init, [0, 1]); + must_be_member(x2_init, [0, 1]); % https://www.sharetechnote.com/html/Handbook_LTE_PseudoRandomSequence.html % https://edadocs.software.keysight.com/pages/viewpage.action?pageId=6076479 diff --git a/matlab/updated_scripts/must_be_member.m b/matlab/updated_scripts/must_be_member.m new file mode 100644 index 0000000..da632ad --- /dev/null +++ b/matlab/updated_scripts/must_be_member.m @@ -0,0 +1,9 @@ +% Replacement for the mustBeMember function that's in MATLAB, but not Octave +% +% Throws an assertion failure if `vector` contains any values not in `valid_values` +% +% @param vector Vector/Matrix of values to check against the list of valid values +% @param valid_values List of value values that can be in any one of the elements of `vector` +function [] = must_be_member(vector, valid_values) + assert(isequal(ismember(vector, valid_values), ones(size(vector)))); +end diff --git a/matlab/updated_scripts/process_file.m b/matlab/updated_scripts/process_file.m index 07194ec..927eb89 100644 --- a/matlab/updated_scripts/process_file.m +++ b/matlab/updated_scripts/process_file.m @@ -10,7 +10,12 @@ % - Print out each frame in hex %% Path Info -this_script_path = fileparts(matlab.desktop.editor.getActiveFilename); +if (is_octave) + this_script_path = fileparts(mfilename('fullpath')); +else + this_script_path = fileparts(matlab.desktop.editor.getActiveFilename); +endif + turbo_decoder_path = fullfile(this_script_path, filesep, '..', filesep, '..', filesep, 'cpp', filesep, 'remove_turbo'); if (~ isfile(turbo_decoder_path)) error("Could not find Turbo decoder application at '%s'. Check that the program has been compiled",...