%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% EE 675 - Fall 2015
%%%% Simple Code to show How to Open the ECG Arrhythmia data sets 
%%%%
%%%% Your project should try to classify different ECG signals 
%%%% Target is to design a system with the best diagnostic performance
%%%%
%%%% Look at "readme.txt" file for content description of data files
%%%%  simple description is in the comments below
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Put your correct file path here
load 'Learndata1.mat'
% check Workspace on Matlab to see that a new variable named Learndata1 of
% size 256x1080 is now available. This array has 256 signals - 64 signals 
% from each of the following 4 types: normal, VCouplet, VTachy,VBigeminy. 

figure(1)
subplot(2,2,1)
plot(Learndata1(1,:))           % example normal signal
xlabel('Time Samples');
title('Normal ECG');

subplot(2,2,2)  
plot(Learndata1(65,:))          % example VCouplet signal
xlabel('Time Samples');
title('Ventricular Couplet ECG');

subplot(2,2,3)
plot(Learndata1(129,:))         % example VTachy signal
xlabel('Time Samples');
title('Ventricular Tachycardia ECG');

subplot(2,2,4)      
plot(Learndata1(197,:))         % example VBigeminy signal
xlabel('Time Samples');
title('Ventricular Bigeminy ECG');

% Put your correct file path here
load 'Learndata2.mat'
figure(2)
subplot(2,1,1), plot(Learndata2(2,:))           % ventricular fibrillation sample 
xlabel('Time Samples');
title('Ventricular Fibrillation ECG');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Note: you can read Testdata1 and Testdata2 the same way
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%%%%% Code to Resample Learndata2/Testdata2  (250 Sa/s -> 360 Sa/s)

Learndata2r= zeros(64,1080);
Testdata2r= zeros(32,1080);

for k1= 1:64
    sig= Learndata2(k1,:);
    rsig= resample(sig, 360, 250); 
    Learndata2r(k1,:)= rsig;
end

load 'Testdata2.mat'

for k1= 1:32
    sig= Testdata2(k1,:);
    rsig= resample(sig, 360, 250); 
    Testdata2r(k1,:)= rsig;
end

save ('Learndata2r','Learndata2r');
save ('Testdata2r','Testdata2r');

rsig= Learndata2r(2,:) 
%figure(3)
subplot(2,1,2), plot((rsig),'r')           % ventricular fibrillation sample 
xlabel('Time Samples');
title('Resampled Ventricular Fibrillation ECG');





