Blame view

tr_merge.m 1.2 KB
45d5c458   Dany Dumont   Premier depot de ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function tr_merge(dev)
% TR_MERGE - Merge trajectories of multiple mat files in a single one,
% supposing that all pieces are parts of the same trajectory.
%
% Syntax:  tr_merge(dev)
% 
% Inputs:
%    dev - name of the device, which appear in the first part of the files
%          to merge.
%
% Example:
%    tr_merge('spot24')
%
%
% Other m-files required: none
% Subfunctions: none
% MAT-files required: Trajectory files to merge.
% 
% See also: TR_MAP, GPX2MAT
% 
% Author: Dany Dumont
% UQAR/ISMER
% email: dany_dumont@uqar.ca
% Website: http://www.ismer.ca/dumont-dany
% September 2014
% ______________________________________________________________________

45d5c458   Dany Dumont   Premier depot de ...
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
curdir = pwd;
matdir = [curdir,'/mat'];

if ~exist(matdir)
    disp(' ERROR : The /mat directory does not exist. Make')
    disp('         sure mat files exist and that they     ')
    disp('         are placed in a directory named mat.   ')
    return
end

files = dir([matdir,'/',dev,'_*.mat']);
nf = length(files);

A = [];
for n = 1:nf
    load([matdir,'/',files(n).name]);
    A = cat(1,A,data);
end

% Sort rows chronologically
A = sortrows(A,1);
% Remove time replicates
A = unique(A,'rows','first');

data = A;

save([matdir,'/',dev,'_merged'],'data');