ubuntu 16 matlab 2015
%%Initialization params
clear all;
all_text_name = importdata('loocv.txt');
rol=1;
subject_01=[];
subject_02=[];
subject_03=[];
subject_04=[];
subject_05=[];
subject_06=[];
subject_07=[];
subject_08=[];
subject_09=[];
subject_10=[];
%=====================================================================================================================================
%get subject name by number
while rol<size(all_text_name,1)+1
text_name = [];
text_name = all_text_name{rol};
subject_number_temp = strsplit(text_name,'_');
subject_number = strsplit(subject_number_temp{2},'s');
subject_number(1)=[]; %delete the blank
switch subject_number{1}
case '01'
subject_01=[subject_01;string(text_name)];
case '02'
subject_02=[subject_02;string(text_name)];
case '03'
subject_03=[subject_03;string(text_name)];
case '04'
subject_04=[subject_04;string(text_name)];
case '05'
subject_05=[subject_05;string(text_name)];
case '06'
subject_06=[subject_06;string(text_name)];
case '07'
subject_07=[subject_07;string(text_name)];
case '08'
subject_08=[subject_08;string(text_name)];
case '09'
subject_09=[subject_09;string(text_name)];
case '10'
subject_10=[subject_10;string(text_name)];
end
rol = rol + 1;
end
%=====================================================================================================================================
%read the data by name
file_label=[];
f=1;
all_data=[];
all_label=[];
subject=subject_10;%%%%!!!!!!!!!
while f<size(subject,1)+1
data=[];
file_label=[];
filename = strcat(subject(f),'.txt');
path_and_name = strcat('YSnew/',filename);
data = textread(char(path_and_name)); %% get the data
label_temp = strsplit(filename,'_');
label = strsplit(label_temp{1},'a');
label(1)=[]; %delete the blank %% get the label
for i=1:size(data,1)
file_label = [file_label;str2double(string(label{1}))]; %% create txt size(label,1)==size(data,1)
end
all_data = [all_data;data];
all_label=[all_label;file_label];
f=f+1;
end
%=====================================================================================================================================
%enveploe
envelope_data = cell(1,8);
for c=1:8
envelope_data{c}=[];
temp_data=[];
temp_data = all_data(:,c);
W=64;
envelope_data{c} = zeros(size(temp_data,1),1);
for i=W/2+1:size(temp_data,1)-W/2
envelope_data{c}(i) = sqrt(mean(temp_data(i-32:i+32).^2));
end
end
%=====================================================================================================================================
%save the data
all_data=[envelope_data{1},envelope_data{2},envelope_data{3},envelope_data{4},envelope_data{5},envelope_data{6},envelope_data{7},envelope_data{8}];
COMPLETE_10=all_data;%%%%!!!!!!!!!
LABEL_10=all_label;%%%%!!!!!!!!!
save('YSdataset_10.mat','COMPLETE_10','LABEL_10');%%%%!!!!!!!!!
% clear all
% load YSdataset.mat