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
load('gps_feature_and.mat')
gap = 1*60*1000 % upsample rate: 1 per minute
epochtime = 1443672000000; % 2015/10/01 12:00 am, used to calculate hour of the day quickly
survey_interval = 14; % cahnge to 14 for phq9
coverpercent_threshod = 0.4; % how many percentage of one survey period needs to be covered
for i = 1:size(gpsData,2)
i
new=[];
temp = gpsData{1,i};
if length(temp)==0
continue;
end
temp(:,5)=0;
temp =sortrows(temp,4);
startt=temp(1,4);
endt=temp(end,4);
len = size(temp,1);
j=1;
c=0;
startt = startt+gap;
for z=[1:100000]
if j+1>len;
break;
end
if temp(j,11)==-3 % no upsampling for activity data
j = j+1;
continue;
end
if temp(j,4)<startt
t = [0 0 0 mod(((temp(j,4)-epochtime)/3600000),24)];
% time dependent
if t(1,4)>=6 & t(1,4)<22
if( temp(j,9)== 7 | 6 )
th=2;
else
th=1;
end
else
th=1;
end
% if temp(j,11) ==-1 % GPS up to 15 minutes
th=1/4;
% end
if t(1,4)>=0 & t(1,4)<6
ttmp = ((temp(j,4)-epochtime)/3600000);
decvalue = ttmp - floor(ttmp/24)*24;
th = min(6,6-decvalue);
end
n=th*3600000/gap;
tmp=temp(j,:);
c=0;
j=j+1;
else
new(end+1,:)=[tmp(1,1:3) startt tmp(1,5:end)];
c=c+1;
startt = startt+gap;
if c>n
startt = temp(j,4);
startt = startt+gap;
end
end
end
gpsData{1,i} = new;
end
%calculate the moving spped
th=1;
c=0
for k = 1:length(gpsData)
tmp = gpsData{1,k};
len = length(tmp);
for l = 2:len
fP1Lat = tmp(l-1,2);
fP1Lon = tmp(l-1,3);
fP2Lat = tmp(l,2);
fP2Lon = tmp(l,3);
fRadLon1 = (pi/180).*(fP1Lon);
fRadLon2 = (pi/180).*(fP2Lon);
fRadLat1 = (pi/180).*(fP1Lat);
fRadLat2 = (pi/180).*(fP2Lat);
fD1 = abs(fRadLat1 - fRadLat2);
fD2 = abs(fRadLon1 - fRadLon2);
fP = power (sin(fD1/2), 2) + cos(fRadLat1) * cos(fRadLat2) * power (sin(fD2/2), 2);
d = 6371.137 * 2 * asin(sqrt(fP)) ;
t = (tmp(l,4)-tmp(l-1,4))/1000;
if (d*3600/t >th)
gpsData{1,k}(l,5)=1;
c=c+1;
gpsData{1,k}(l-1,5)=1;
end
end
end
id = cellfun('length',gpsData);
gpsData(id==0)=[];
for k = 1:length(gpsData)
remove = [];
tmp = gpsData{1,k};
len = length(tmp);
for l = 2:len
if(tmp(l,4)-tmp(l-1,4)==0)
remove=[remove;l];
end
end
tmp(remove,:) = [];
gpsData{1,k} = tmp;
end
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
%calculate the time coverage
relen = [];
for i =1:length(gpsData)
tmp = gpsData{1,i};
relen=[relen length(tmp)];
end
save('gps_feature_and_up_shweta.mat','gpsData');