diff --git a/matlab/updated_scripts/get_sample_count_of_file.m b/matlab/updated_scripts/get_sample_count_of_file.m new file mode 100644 index 0000000..72690bf --- /dev/null +++ b/matlab/updated_scripts/get_sample_count_of_file.m @@ -0,0 +1,16 @@ +% Get the number of complex 32-bit floating point values in the specified file +% +% @param file_path Path to the file that contains complex 32-bit floating point samples +% @return sample_count Number of complex 32-bit floating point samples in the provided input file +function [sample_count] = get_sample_count_of_file(file_path) + handle = fopen(file_path, "r"); + if (handle == 0) + error("Could not open input file '%s'"', file_path); + end + + fseek(handle, 0, 'eof'); + byte_count = ftell(handle); + fclose(handle); + + sample_count = floor(byte_count / 4 / 2); +end \ No newline at end of file