%% Question 1

ohms = load('testresist.dat');
meanOhms = mean(ohms)
medianOhms = median(ohms)
modeOhms = mode(ohms)
stdOhms = std(ohms)
n = length(find(abs(ohms - 500) / 500 < 0.01))


%% Question 2

x = load('noisy.dat');
plot(x)
figure
plot(medfilter(x, 5))
figure
plot(medfilter(x, 51))
figure
plot(medfilter(x, 151))

% The filtered part of the signal appears smoother as the filter size
% increases.
% The filter distorts the shape of the minima and maxima of the sine wave
% at large filter sizes because the median over 151 elements can never
% reach +/-1.


%% Question 3
[uN, rN, vN, uG, rG, vG] = textread('results.txt', '%f %f %f %f %f %f\n', ...
    'headerlines', 4);
boxplot([uN uG], {'navigated', 'guide'});
ylabel('ulnar variance error (mm)')
title('ulnar variance correction error');

figure
boxplot([rN rG], {'navigated', 'guide'});
ylabel('radial inclination error (degrees)')
title('radial inclination correction error');

figure
boxplot([vN vG], {'navigated', 'guide'});
ylabel('volar tilt error (degrees)')
title('volar tilt correction error');

% The median errors for both techniques are similar and close to zero.
% The spread in the errors is much smaller for the guide technique,
% especially in terms of ulnar variance error and radial inclination
% error (i.e., the guide technique produces more consistent results).
% Even though the total range of volar tilt error is larger for the
% guide group, the interquartile range is smaller for the guide
% group when compared to the navigated group.
