Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
clc, clear all, close all
file=dir('android_remdup\*');
gpsData=cell(1,length(file)-2);
x=1; % survey period counter
survey_interval = 14; % cahnge to 14 for phq9
coverday_threshod = 4; % how many days need to be covered in one period
accth = 165; % threshold for accuracy
for n=3:length(file)
file(n).name
tmp=csvread(['android_remdup\',file(n).name],1,0);
tmp=sortrows(tmp,4);
tmp=[tmp ones(length(tmp),1).*-1];
dep = tmp(1,8);
wifitmp=csvread(['wifiprocess\',file(n).name],1,0);
for i=2:length(wifitmp(:,1)) % disconnection events
if wifitmp(i,3)==0
wifitmp(i,1:2)=wifitmp(i-1,1:2);
end
end
wifitmp(find(wifitmp(:,1)==-1),:)=[]; % no GPS matched
wifitmp(find(wifitmp(:,2)==-1),:)=[];
wifitmp=[zeros(length(wifitmp(:,1)),1) wifitmp(:,2) wifitmp(:,1) wifitmp(:,4) ones(length(wifitmp(:,1)),1).*tmp(1,5) ones(length(wifitmp(:,1)),1).*-1 ones(length(wifitmp(:,1)),1).*-1 ones(length(wifitmp(:,1)),1).*-1 ones(length(wifitmp(:,1)),1).*-1 wifitmp(:,3).*-2];
gpsTime = datestr(wifitmp(:,4)/86400000 + datenum(1970,1,1));
t = datetime(gpsTime, 'Format', 'dd/M/yy HH:mm:ss');
t = datevec(t);
tmp = [tmp;wifitmp];
tmp=sortrows(tmp,4);
actitmp_=[];
actitmp=csvread(['actiprocess\',file(n).name],1,0);
actitmp = actitmp(find(actitmp(:,3)<max(tmp(:,4))&actitmp(:,3)>min(tmp(:,4))),:);
actitmp = actitmp(find(actitmp(:,4)>=3&actitmp(:,7)>50),:);%moving with accuracy>50
fill = zeros(length(actitmp(:,1)),1);
actitmp_=[fill fill fill actitmp(:,3) fill fill fill fill actitmp(:,2) ones(length(actitmp(:,1)),1).*3];
gpsTime = datestr(actitmp_(:,4)/86400000 + datenum(1970,1,1));
t = datetime(gpsTime, 'Format', 'dd/M/yy HH:mm:ss');
t = datevec(t);
tmp = [tmp;actitmp_];
tmp=sortrows(tmp,4);
% update the survey date for wifi data
unip = sortrows(unique(tmp(:,9)),1);
unip(find(unip(:)==-1))=[];
for i = 2:length(tmp)
if tmp(i,6)==-1
for j=1:length(unip)
if (tmp(i,4)<unip(j))&&(tmp(i,4)>unip(j)-survey_interval*1440*60*1000)
tmp(i,9)= unip(j); tmp(i,8)= dep;
break
end
end
end
end
% aplit data based on survey date
unip = sortrows(unique(tmp(:,9)),1);
unip(find(unip(:)==-1))=[];
unip(find(unip(:)<1.4*10^12))=[];
for i=1:length(unip)
index = find(tmp(:,9)==unip(i));
if length(index)>100
gpsData{1,x}=[ones(length(index),1).*unip(i) tmp(index,[2:4]) zeros(length(index),1) tmp(index,5:7) zeros(length(index),1) tmp(index,[8 10])];
gpsData{1,x}=gpsData{1,x}(find(gpsData{1,x}(:,8)<=accth),:);
gpsData{1,x}=sortrows(gpsData{1,x},4);
x=x+1;
end
end
file(n).name;
end
%calculate week day
for i = 1:size(gpsData,2)
temp = size(gpsData{1,i},2);
% Get day of the week info
wd = weekday(datestr(gpsData{1,i}(:,4)/86400000 + datenum(1970,1,1)));
gpsData{1,i}(:,9) = wd;
end
% calculate number of days covered in one period
sdc=[]
for i = 1:size(gpsData,2)
temp = gpsData{1,i};
if length(temp)==0
continue;
end
dc =1;
for di=2:length(temp)
if temp(di,9)~=temp(di-1,9)
dc=dc+1;
end
end
sdc = [sdc dc];
end
gpsData(find(sdc(1,:)<=coverday_threshod))=[];
id = cellfun('length',gpsData);
gpsData(id==0)=[]
save('gps_feature_and.mat','gpsData');