diff --git a/README b/README index e69de29..f17f3ac 100644 --- a/README +++ b/README @@ -0,0 +1,3 @@ +We recommend you to install pahsed array system toolbox for MATLAB 2018. +Load samples and demodulate using "load_data.m". +You can generate your own FMCW signal using FMCWWaveform() on Matlab. \ No newline at end of file diff --git a/load_samples.m b/load_samples.m new file mode 100644 index 0000000..944ea30 --- /dev/null +++ b/load_samples.m @@ -0,0 +1,37 @@ +function [samples, n_samples] = load_samples(samplefilepath, format, little_endian, nr) + %%%%%%%%%%%%%%%%%%%%%% + %% read the samples + %%%%%%%%%%%%%%%%%%%%%% + + if nargin < 4 + nr = inf; + end + if nargin > 1 && strcmp(format,'cplx') + fid = fopen(samplefilepath, 'r'); + if (nargin < 3) + little_endian = false; + end + if (little_endian) + [s, n] = fread(fid, nr, 'int32', 0, 'ieee-le'); + else + [s, n] = fread(fid, nr, 'int32', 0, 'ieee-be'); + end + fclose(fid); + s = reshape(s, 2, []).'; + s = s(:,1) + 1i * s(:,2); + n = n/2; + end + + if nargin > 1 && strcmp(format,'float32') + fid = fopen(samplefilepath, 'r'); + [s, n] = fread(fid, nr, 'float'); + fclose(fid); + s = reshape(s, 2, []).'; + s = s(:,1) + 1i * s(:,2); + n = n/2; + end + + s(1:10,:) + samples = s; + n_samples = n; +end \ No newline at end of file