-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcalculate_statistics.m
39 lines (37 loc) · 1.32 KB
/
calculate_statistics.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function statistics_table=calculate_statistics(frequency,measured,predicted,compensated)
%=========================================================================
%function CALCULATE_STATISTICS
% 1) Calculates the R^2 value
% 2) Calculates the RMS before and after compensation
% 3) Calculates the RMS reduction percentage
%
%-------
%Inputs
%-------
% frequency (Nfrequencies x 1) Vector of the range of cutoff
% frequencies
% uncompensated (Nfrequencies x 1) Vector of the uncompensated moment
% compensated (Nfrequencies x 1) Vector of the compensated moment
%--------
%Outputs
%--------
% Automatically generates a table of statistics of R^2, RMS before and
% after compensation, and the percent difference in RMS
%=========================================================================
%----------------
%R^2
%----------------
Ssres=sum(((measured-predicted).^2));
Sstotal=sum(((measured-mean(measured)).^2));
rsq=1-Ssres/Sstotal;
%----------------
%RMS Reduction
%----------------
compensated=sqrt(mean(compensated.^2));
uncompensated=sqrt(mean(measured.^2));
difference=((uncompensated-compensated)/uncompensated)*100;
%----------------
%Create Table
%----------------
statistics_table=[frequency rsq uncompensated compensated difference];
end