Skip to content
Snippets Groups Projects
Commit 486491b3 authored by Rexer, Manuel's avatar Rexer, Manuel
Browse files

added deadtime and calculation of overall uncertainty

parent 322c52a4
Branches
Tags v1.4.0
1 merge request!2Update from Dissertation Rexer
...@@ -60,21 +60,21 @@ defaultHys = 0; ...@@ -60,21 +60,21 @@ defaultHys = 0;
defaultFreq = []; defaultFreq = [];
p = inputParser; p = inputParser;
validScalarPosNum = @(x) isnumeric(x) && (x > 0); validScalarPosNum = @(x) isnumeric(x) && (x >= 0);
addOptional(p, 'bias', defaultBias, validScalarPosNum); addOptional(p, 'bias', defaultBias, validScalarPosNum);
addOptional(p, 'slope', defaultSlope, validScalarPosNum); addOptional(p, 'sensitivity', defaultSlope, validScalarPosNum);
addOptional(p, 'lin', defaultLin, validScalarPosNum); addOptional(p, 'linearity', defaultLin, validScalarPosNum);
addOptional(p, 'hys', defaultHys, validScalarPosNum); addOptional(p, 'hysteresis', defaultHys, validScalarPosNum);
addOptional(p, 'excitation_frequency', defaultFreq, validScalarPosNum) addOptional(p, 'excitation_frequency', defaultFreq, validScalarPosNum)
parse(p, varargin{:}) parse(p, varargin{:})
%% Generate the uncertainty data structure with the given input arguments %% Generate the uncertainty data structure with the given input arguments
data.uncertainty.systematic.bias = p.Results.bias; data.uncertainty.systematic.bias = p.Results.bias;
data.uncertainty.systematic.slope = p.Results.slope; data.uncertainty.systematic.slope = p.Results.sensitivity;
data.uncertainty.systematic.lin = p.Results.lin; data.uncertainty.systematic.lin = p.Results.linearity;
data.uncertainty.systematic.hys = p.Results.hys; data.uncertainty.systematic.hys = p.Results.hysteresis;
result_struct.excitation_frequency = p.Results.excitation_frequency; result_struct.excitation_frequency = p.Results.excitation_frequency;
%% Pre Process the data %% Pre Process the data
...@@ -107,11 +107,14 @@ result_struct.number_of_cycles = getNumberOfCycles(time_vector, result_struct.ex ...@@ -107,11 +107,14 @@ result_struct.number_of_cycles = getNumberOfCycles(time_vector, result_struct.ex
result_struct.FFT.N_data_points_in_FFT = length(result_struct.value_mean_vector); result_struct.FFT.N_data_points_in_FFT = length(result_struct.value_mean_vector);
result_struct.FFT.value = fft(result_struct.value_mean_vector); result_struct.FFT.value = fft(result_struct.value_mean_vector);
% result_struct.FFT.N_data_points_in_FFT = length(value_vector);
% result_struct.FFT.value = fft(value_vector);
% Calculate the statistical uncertainty % Calculate the statistical uncertainty
% TODO: Maybe also write a test for the statistical uncertainty % TODO: Maybe also write a test for the statistical uncertainty
temp_term1 = result_struct.value_standartdeviation_vector * tinv(1 - (0.05/2), result_struct.number_of_cycles-1); temp_term1 = result_struct.value_standartdeviation_vector * tinv(1 - (0.05/2), result_struct.number_of_cycles-1)/sqrt(result_struct.number_of_cycles);
temp_term2 = (sqrt(result_struct.number_of_cycles))^2 * result_struct.FFT.N_data_points_in_FFT; temp_term2 = result_struct.FFT.N_data_points_in_FFT;
data.uncertainty.statistical = sqrt(sum(temp_term1 / temp_term2)); data.uncertainty.statistical = sqrt(sum(temp_term1.^2) / temp_term2);
clearvars temp_term1 temp_term2 clearvars temp_term1 temp_term2
% Scale coefficients of the FFT % Scale coefficients of the FFT
...@@ -135,6 +138,14 @@ clearvars temp_term1 temp_term2 ...@@ -135,6 +138,14 @@ clearvars temp_term1 temp_term2
data.uncertainty.systematic.hys, ... data.uncertainty.systematic.hys, ...
result_struct.FFT.value); result_struct.FFT.value);
%% Calculate uncertainty rising from sampling rate
% Asumption: the actually measured value can is inbetween two sample points
% therefore we ad an deadtime uncertainty of +- sampletime
% This affects only the phase of the measurement in frequency domain
result_struct.FFT.uncertainty.deadtime.phase = 0.5*0.95*sampletime*2*pi*result_struct.FFT.frequencies;
result_struct.FFT.uncertainty.deadtime.absolute = 0*result_struct.FFT.frequencies;
%% Calculate resulting overall uncertainty %% Calculate resulting overall uncertainty
% random uncertainty % random uncertainty
...@@ -150,22 +161,35 @@ result_struct.FFT.uncertainty.statistical.phase(1) = 0; ...@@ -150,22 +161,35 @@ result_struct.FFT.uncertainty.statistical.phase(1) = 0;
% sum up % sum up
result_struct.FFT.uncertainty.absolute = sqrt(... result_struct.FFT.uncertainty.absolute = sqrt(...
result_struct.FFT.uncertainty.statistical.absolute.^2 +... result_struct.FFT.uncertainty.statistical.absolute.^2 +...
result_struct.FFT.uncertainty.systematic.absolute.^2 ); result_struct.FFT.uncertainty.systematic.absolute.^2 +...
result_struct.FFT.uncertainty.deadtime.absolute.^2);
result_struct.FFT.uncertainty.phase = sqrt(... result_struct.FFT.uncertainty.phase = sqrt(...
result_struct.FFT.uncertainty.statistical.phase.^2 +... result_struct.FFT.uncertainty.statistical.phase.^2 +...
result_struct.FFT.uncertainty.systematic.phase.^2 ); result_struct.FFT.uncertainty.systematic.phase.^2 +...
result_struct.FFT.uncertainty.deadtime.phase.^2 );
% conversion
temp1=atan(result_struct.FFT.uncertainty.phase).*abs(result_struct.FFT.value); % conversion from abs and phase to real and imag (complex number)
temp2= result_struct.FFT.uncertainty.absolute.*cos(angle(result_struct.FFT.value))+...
1i*result_struct.FFT.uncertainty.absolute.*sin(angle(result_struct.FFT.value)); % Ansatz: gausian uncertaintypropagation
temp1=temp1.*cos(angle(result_struct.FFT.value)+pi/2)+... result_struct.FFT.uncertainty.real = sqrt(cos(angle(result_struct.FFT.value)).^2.*result_struct.FFT.uncertainty.absolute.^2+...
1i*temp1.*sin(angle(result_struct.FFT.value)+pi/2); abs(result_struct.FFT.value).^2.*sin(angle(result_struct.FFT.value)).^2.*result_struct.FFT.uncertainty.phase.^2);
result_struct.FFT.uncertainty.complex = ... result_struct.FFT.uncertainty.imag = sqrt(sin(angle(result_struct.FFT.value)).^2.*result_struct.FFT.uncertainty.absolute.^2+...
abs(real(temp1))+abs(real(temp2))+... abs(result_struct.FFT.value).^2.*cos(angle(result_struct.FFT.value)).^2.*result_struct.FFT.uncertainty.phase.^2);
1i*(abs(imag(temp1))+abs(imag(temp2)));
clear temp1 temp2 result_struct.FFT.uncertainty.complex = result_struct.FFT.uncertainty.real+1i*result_struct.FFT.uncertainty.imag;
% Maximum estimation according to Rexer, not realy sutable
% temp1=atan(result_struct.FFT.uncertainty.phase).*abs(result_struct.FFT.value);
% temp2= result_struct.FFT.uncertainty.absolute.*cos(angle(result_struct.FFT.value))+...
% 1i*result_struct.FFT.uncertainty.absolute.*sin(angle(result_struct.FFT.value));
% temp1=temp1.*cos(angle(result_struct.FFT.value)+pi/2)+...
% 1i*temp1.*sin(angle(result_struct.FFT.value)+pi/2);
%
% result_struct.FFT.uncertainty.complex = ...
% abs(real(temp1))+abs(real(temp2))+...
% 1i*(abs(imag(temp1))+abs(imag(temp2)));
% clear temp1 temp2
% Mapping % Mapping
......
...@@ -34,13 +34,13 @@ function [systematic_uncertainty_absolute, ... ...@@ -34,13 +34,13 @@ function [systematic_uncertainty_absolute, ...
% (not always given)* obtained from the data sheet of the sensor that was % (not always given)* obtained from the data sheet of the sensor that was
% used for the measurement or from calibration protocols. % used for the measurement or from calibration protocols.
% Use 0 if there isn't a given value for your sensor. % Use 0 if there isn't a given value for your sensor.
%
% -- sysunc_hysteresis scalar (1-by-1) real number of type double that % -- sysunc_hysteresis scalar (1-by-1) real number of type double that
% represents the *hysteresis* systematic uncertainty and can be % represents the *hysteresis* systematic uncertainty and can be
% *sometimes (not always given)* obtained from the data sheet of the % *sometimes (not always given)* obtained from the data sheet of the
% sensor that was used for the measurement or from calibration protocols. % sensor that was used for the measurement or from calibration protocols.
% Use 0 if there isn't a given value for your sensor. % Use 0 if there isn't a given value for your sensor.
%
% -- FFT_Mean FFT of the mean value vector of the "statistic % -- FFT_Mean FFT of the mean value vector of the "statistic
% oscillation". % oscillation".
% %
...@@ -56,8 +56,12 @@ function [systematic_uncertainty_absolute, ... ...@@ -56,8 +56,12 @@ function [systematic_uncertainty_absolute, ...
% given sensor. % given sensor.
systematic_uncertainty_absolute = sysunc_bias + sysunc_slope + (0.608 * sysunc_linearity); systematic_uncertainty_absolute = ones(1,length(FFT_Mean)).*...
systematic_uncertainty_phase = atan(0.681 * sysunc_hysteresis ./ abs(FFT_Mean)); ((0.95*sysunc_slope.*abs(FFT_Mean)) + (0.263 * sysunc_linearity));
systematic_uncertainty_absolute(1) = (0.95*sysunc_bias) + (0.95*sysunc_slope.*abs(FFT_Mean(1))) + (0.263 * sysunc_linearity);
systematic_uncertainty_phase = atan(0.235 * sysunc_hysteresis ./ abs(FFT_Mean));
systematic_uncertainty_phase (1) = 0;
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment