
%*************************************************************************************
%close all
%clear;

% Definitions spectra and glucose reading arrays to operate on ********************
ycalavg = avp(ycal3,6);
zcalavg = avp(zcal,6);

[N1 M1] = size(ycalavg);
mcal=[1:N1];
[N2 M2] = size(uavg);
mprd=[1:N2];

%Validation ************************************************************************************

%zcalavg=zcalavg';
%Fig1
[totalClark, percentClark] = clarke(ycalavg,zcalavg);

%Fig2
%mdlcal = fitlm(ycalavg,zcalavg); %returns a linear regression model of the responses y, fit to the data matrix X.
%anova(mdlcal,'summary'); %test fit by anova
%figure;plot(mdlcal);title('Validation'); xlabel('Reference Concentration [mg/dL]'); ylabel('Predicted Concentration [mg/dL]');

%Fig3
figure;plot(mcal,ycalavg,'-ro',mcal,zcalavg,'-bo');title('Validation'); xlabel('Record Number]'); ylabel('Concentration [mg/dL]');
legend('Reference', 'Predicted');

%Prediction************************************************************************************

%Fig4
[totalClark, percentClark] = clarke(uavg,wavg);

%Fig5
%mdlpred = fitlm(uavg,wavg); %returns a linear regression model of the responses y, fit to the data matrix X.
%anova(mdlpred,'summary'); %test fit by anova
%figure;plot(mdlpred);
%title('Prediction'); xlabel('Reference Concentration [mg/dL]'); ylabel('Predicted Concentration [mg/dL]');

%Fig6
figure;plot(mprd,uavg,'-ro',mprd,wavg,'-bo')
title('Prediction'); xlabel('Record Number]'); ylabel('Concentration [mg/dL]');
legend('Reference', 'Predicted');
%************************************************************************************

%Fig7
%figure;plot(ycalavg-zcalavg); title('Val Differences');
%Fig8
%figure;plot(uavg-wavg); title('Pred Differences');

