Commit cdf1dae5 authored by Jan-Gerrit Richter's avatar Jan-Gerrit Richter

bugfix: betarange betares more stable comparison

parent aa9313e9
......@@ -20,7 +20,7 @@ function [] = daffv17_write( varargin )
% 'MPS' => Magnitude phase spectra,
% 'DFT' => discrete fourier spectra)
% datafunc function Data function (delivers the data for a direction)
% orient vector-3 Orientation [yaw pitch roll] angles []
% orient vector-3 Orientation [yaw pitch roll] angles [°]
% channels int Number of channels
%
% alphares float Resolution of alpha-angles
......@@ -300,7 +300,7 @@ function [] = daffv17_write( varargin )
if isfield(args, 'betares')
args.betapoints = (betaspan / args.betares) + 1;
if (ceil(args.betapoints) ~= args.betapoints)
if (abs(args.betapoints - round(args.betapoints)) > 1e-5 )
error('Beta range and beta resolution are not an integer multiple')
end
else
......@@ -371,17 +371,17 @@ function [] = daffv17_write( varargin )
fprintf('Content type: \t%s\n', contentStr);
fprintf('Num channels: \t%d\n', args.channels);
fprintf('Num alpha points: \t%d\n', args.alphapoints);
fprintf('Alpha range: \t[%0.1f, %0.1f]\n', alphastart, alphaend);
fprintf('Alpha resolution: \t%0.1f\n', args.alphares);
fprintf('Alpha range: \t[%0.1f°, %0.1f°]\n', alphastart, alphaend);
fprintf('Alpha resolution: \t%0.1f°\n', args.alphares);
fprintf('Num beta points: \t%d\n', args.betapoints);
fprintf('Beta range: \t[%0.1f, %0.1f]\n', betastart, betaend);
fprintf('Beta resolution: \t%0.1f\n', args.betares);
fprintf('Beta range: \t[%0.1f°, %0.1f°]\n', betastart, betaend);
fprintf('Beta resolution: \t%0.1f°\n', args.betares);
fprintf('Measurement dist.: \t%0.2f m\n', args.mdist);
fprintf('Reference value: \t%+0.1f dB\n', args.reference);
fprintf('Orientation: \t(Y%+0.1f, P%+0.1f, R%+0.1f)\n', ...
fprintf('Orientation: \t(Y%+0.1f°, P%+0.1f°, R%+0.1f°)\n', ...
args.orient(1), args.orient(2), args.orient(3));
if strcmp(args.content, 'IR')
......@@ -448,20 +448,20 @@ function [] = daffv17_write( varargin )
[ channels, filterlength] = size( data );
if( ~isa( data, 'numeric' ) )
error( 'Dataset (A%0.1f, B%0.1f): Data function must deliver double values', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Data function must deliver double values', alpha, beta );
end
if isfield( props, 'samplerate' )
if (samplerate ~= props.samplerate)
error( 'Dataset (A%0.1f, B%0.1f): Sampling rate does not match', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Sampling rate does not match', alpha, beta );
end
if (channels ~= args.channels)
error( 'Dataset (A%0.1f, B%0.1f): Number of channels does not match', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Number of channels does not match', alpha, beta );
end
if (filterlength ~= props.filterlength)
error( 'Dataset (A%0.1f, B%0.1f): Filter length does not match', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Filter length does not match', alpha, beta );
end
else
% Now set the global properties, if they have not been set yet
......@@ -471,7 +471,7 @@ function [] = daffv17_write( varargin )
% Check filter length for 16-byte alignment
if( mod( filterlength, 4 ) ~= 0 )
error( 'Dataset (A%0.1f, B%0.1f): Filter length is %d which is not a multiple of 4 (this is required for memory alignment)', alpha, beta, filterlength );
error( 'Dataset (A%0.1f°, B%0.1f°): Filter length is %d which is not a multiple of 4 (this is required for memory alignment)', alpha, beta, filterlength );
end
fprintf('Global properties: Sampling rate = %d Hz, filter length = %d\n',...
......@@ -547,33 +547,33 @@ function [] = daffv17_write( varargin )
[channels, numfreqs] = size(data);
if ~isa( data, 'numeric' )
error( 'Dataset (A%0.1f, B%0.1f): Data function must deliver double values', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Data function must deliver double values', alpha, beta );
end
if isfield( props, 'freqs' )
if freqs ~= props.freqs
error( 'Dataset (A%0.1f, B%0.1f): Frequency support does not match', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Frequency support does not match', alpha, beta );
end
if (channels ~= args.channels)
error( sprintf('Dataset (A%0.1f, B%0.1f): Number of channels does not match', alpha, beta) );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Number of channels does not match', alpha, beta) );
end
else
% Checks on the frequency support
if (numfreqs ~= size(freqs))
error( sprintf('Dataset (A%0.1f, B%0.1f): Frequency support does not match', alpha, beta) );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Frequency support does not match', alpha, beta) );
end;
if (min(freqs) <= 0)
error( sprintf('Dataset (A%0.1f, B%0.1f): Support frequencies must be greater zero', alpha, beta) );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Support frequencies must be greater zero', alpha, beta) );
end;
if (sort(freqs) ~= freqs)
error( sprintf('Dataset (A%0.1f, B%0.1f): Support frequencies must be stricly increasing', alpha, beta) );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Support frequencies must be stricly increasing', alpha, beta) );
end
if (length(unique(freqs)) ~= length(freqs))
error( sprintf('Dataset (A%0.1f, B%0.1f): Support frequencies must be unique', alpha, beta) );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Support frequencies must be unique', alpha, beta) );
end
% Now set the global properties, if they have not been set yet
......@@ -586,7 +586,7 @@ function [] = daffv17_write( varargin )
% Important: Negative magnitudes are forbidden
if min( min( data ) ) < 0
error( 'Dataset (A%0.1f, B%0.1f): Contains negative magnitudes', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Contains negative magnitudes', alpha, beta );
end
......@@ -616,29 +616,29 @@ function [] = daffv17_write( varargin )
[channels, numfreqs] = size(data);
if (class(data) ~= 'double')
error( sprintf('Dataset (A%0.1f, B%0.1f): Data function must deliver double values') );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Data function must deliver double values') );
end
if isfield(props, 'freqs')
if (freqs ~= props.freqs)
error( sprintf('Dataset (A%0.1f, B%0.1f): Frequency support does not match', alpha, beta) );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Frequency support does not match', alpha, beta) );
end
if (channels ~= args.channels)
error( sprintf('Dataset (A%0.1f, B%0.1f): Number of channels does not match', alpha, beta) );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Number of channels does not match', alpha, beta) );
end
else
% Checks on the frequency support
if (min(freqs) <= 0)
error( sprintf('Dataset (A%0.1f, B%0.1f): Support frequencies must be greater zero', alpha, beta) );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Support frequencies must be greater zero', alpha, beta) );
end;
if (sort(freqs) ~= freqs)
error( sprintf('Dataset (A%0.1f, B%0.1f): Support frequencies must be stricly increasing', alpha, beta) );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Support frequencies must be stricly increasing', alpha, beta) );
end
if (length(unique(freqs)) ~= length(freqs))
error( sprintf('Dataset (A%0.1f, B%0.1f): Support frequencies must be unique', alpha, beta) );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Support frequencies must be unique', alpha, beta) );
end
% Now set the global properties, if they have not been set yet
......@@ -651,7 +651,7 @@ function [] = daffv17_write( varargin )
% Important: Phases must range between +-pi
if (min(min(data)) < -pi) || (max(max(data)) > pi)
error( sprintf('Dataset (A%0.1f, B%0.1f): Phases must range between +-pi', alpha, beta) );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Phases must range between +-pi', alpha, beta) );
end
props.globalPeak = 0;
......@@ -675,29 +675,29 @@ function [] = daffv17_write( varargin )
[channels, numfreqs] = size(data);
if ~isa( data, 'numeric' )
error( 'Dataset (A%0.1f, B%0.1f): Data function must deliver double values', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Data function must deliver double values', alpha, beta );
end
if isfield( props, 'freqs' )
if freqs ~= props.freqs
error( 'Dataset (A%0.1f, B%0.1f): Frequency support does not match', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Frequency support does not match', alpha, beta );
end
if channels ~= args.channels
error( 'Dataset (A%0.1f, B%0.1f): Number of channels does not match', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Number of channels does not match', alpha, beta );
end
else
% Checks on the frequency support
if min(freqs) <= 0
error( 'Dataset (A%0.1f, B%0.1f): Support frequencies must be greater zero', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Support frequencies must be greater zero', alpha, beta );
end;
if sort(freqs) ~= freqs
error( 'Dataset (A%0.1f, B%0.1f): Support frequencies must be stricly increasing', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Support frequencies must be stricly increasing', alpha, beta );
end
if length(unique(freqs)) ~= length(freqs)
error( 'Dataset (A%0.1f, B%0.1f): Support frequencies must be unique', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Support frequencies must be unique', alpha, beta );
end
% Now set the global properties, if they have not been set yet
......@@ -731,30 +731,30 @@ function [] = daffv17_write( varargin )
[ channels, numDFTCoeffs ] = size( data );
if ~isa( data, 'double' )
error( 'Dataset (A%0.1f, B%0.1f): Data function must deliver double values', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Data function must deliver double values', alpha, beta );
end
if channels ~= args.channels
error( 'Dataset (A%0.1f, B%0.1f): Data function must deliver matching channel numbers (%d != %d) ', alpha, beta, args.channels, channels );
error( 'Dataset (A%0.1f°, B%0.1f°): Data function must deliver matching channel numbers (%d != %d) ', alpha, beta, args.channels, channels );
end
if isa( isSymetric, 'logical' ) == 0
error( 'Dataset (A%0.1f, B%0.1f): third parameter isSymetric must be logical', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): third parameter isSymetric must be logical', alpha, beta );
end
if isfield( props, 'samplerate' )
if ( sampleRate ~= props.sampleRate )
error( 'Dataset (A%0.1f, B%0.1f): Sample rate does not match', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Sample rate does not match', alpha, beta );
end
end
if isfield( props, 'numDFTCoeffs' )
if( numDFTCoeffs ~= props.numDFTCoeffs )
error( 'Dataset (A%0.1f, B%0.1f): Number of discrete fourier spectra coefficients is not constant', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Number of discrete fourier spectra coefficients is not constant', alpha, beta );
end
else
if( numDFTCoeffs <= 0 )
error( 'Dataset (A%0.1f, B%0.1f): Number of discrete fourier spectra coefficients must be greater than zero', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Number of discrete fourier spectra coefficients must be greater than zero', alpha, beta );
end
props.numDFTCoeffs = numDFTCoeffs;
......@@ -1007,13 +1007,13 @@ function [] = daffv17_write( varargin )
[ data, ~, ~ ] = args.datafunc( alpha, beta, args.userdata );
if( ~isa( data, 'double' ) )
error( 'Dataset (A%0.1f, B%0.1f): Data function must deliver double values', alpha, beta );
error( 'Dataset (A%0.1f°, B%0.1f°): Data function must deliver double values', alpha, beta );
end
% Clipping check
peak = max(max(abs(data)));
if ( peak > 1 ) && ( ~args.quiet ) && ( quantizationType ~= 2 )
warning( 'Dataset (A%0.1f, B%0.1f): Clipping occured (peak %0.3f)', alpha, beta, peak );
warning( 'Dataset (A%0.1f°, B%0.1f°): Clipping occured (peak %0.3f)', alpha, beta, peak );
end
for c=1:args.channels
......@@ -1064,13 +1064,13 @@ function [] = daffv17_write( varargin )
[channels, numfreqs] = size(data);
if (class(data) ~= 'double')
error( sprintf('Dataset (A%0.1f, B%0.1f): Data function must deliver double values') );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Data function must deliver double values') );
end
% Clipping check
peak = max(max(data));
if ( peak > 1.0 ) && ( ~args.quiet ) && ( quantizationType ~= 2 )
warning( 'Dataset (A%0.1f, B%0.1f): Clipping occured (peak %0.3f)', alpha, beta, peak );
warning( 'Dataset (A%0.1f°, B%0.1f°): Clipping occured (peak %0.3f)', alpha, beta, peak );
end
%x{a,b}.dataOffset = zeros(1, args.channels);
......@@ -1107,7 +1107,7 @@ function [] = daffv17_write( varargin )
[channels, numfreqs] = size(data);
if (class(data) ~= 'double')
error( sprintf('Dataset (A%0.1f, B%0.1f): Data function must deliver double values') );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Data function must deliver double values') );
end
%x{a,b}.dataOffset = zeros(1, args.channels); TODO
......@@ -1143,7 +1143,7 @@ function [] = daffv17_write( varargin )
[ channels, numfreqs ] = size( data );
if (class(data) ~= 'double')
error( sprintf('Dataset (A%0.1f, B%0.1f): Data function must deliver double values') );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Data function must deliver double values') );
end
%x{a,b}.dataOffset = zeros(1, args.channels); TODO
......@@ -1183,7 +1183,7 @@ function [] = daffv17_write( varargin )
[ channels, numfreqs ] = size( data );
if (class(data) ~= 'double')
error( sprintf('Dataset (A%0.1f, B%0.1f): Data function must deliver double values') );
error( sprintf('Dataset (A%0.1f°, B%0.1f°): Data function must deliver double values') );
end
%x{a,b}.dataOffset = zeros(1, args.channels); TODO
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment