-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_data.m
45 lines (39 loc) · 1.23 KB
/
update_data.m
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function data=update_data(savedata,updatedata,loaddata,data,data_path,datafile,field,update)
%data=update_data(savedata,updatedata,loaddata,data,data_path,datafile,field,update)
%
% update data
% if field and update are indicated then each trial can be updated with
% the same information
% if field==[], then each trial can updated individually depending on
% the value of data
%
% Corentin Massot
% Cognition and Sensorimotor Integration Lab, Neeraj J. Gandhi
% University of Pittsburgh
% created 10/16/2016 last modified 10/16/2016
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if updatedata,
display(['updating data: offline.' field])
%load data
if loaddata
display('loading data...')
load ([data_path datafile]);
else
if isempty(data)
display('Warning: data is empty')
pause
end
end
%update field
if ~isempty(field),
for d=1:numel(data)
eval(['data(d).offline.' field '=update;']);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%save
if savedata
display(['saving updated data: offline.' field])
save([data_path datafile], 'data')
end