but_punch_out_Callback.m 1.17 KB
function but_punch_out_Callback(hObject, eventdata, handles)

global S O cnt

I0    = str2num(handles.edit_I0.String);
If    = str2num(handles.edit_If.String);
I     = handles.menu_files.Value; 
fname = handles.menu_files.String{I}(1:end-4) ;

%% Make output structure
O                      = [] ;
O.lon                  = S.lon(I0:If) ;
O.lat                  = S.lat(I0:If) ;
O.dnum                 = S.dnum(I0:If) ;
[O.u,O.v,O.spd,O.head] = llt2spd(O.lon,O.lat,O.dnum) ;
if isfield(S,'z'); O.z = S.z(I0:If) ; end

save(['data/gps/clean/' fname '_' sprintf('%03d',cnt) '.mat'],'O') ; cnt = cnt+1 ;

%% Cut this data from the S raw structure
S.lon(I0:If)  = [];
S.lat(I0:If)  = [];
S.dnum(I0:If) = [];
if isfield(S,'z'); S.z(I0:If) = [] ; end

% write to logfile
newN = numel(S.dnum) ; % track size
fprintf(handles.logfid,'%s,%d,%d,%f,%d\n','output',I0,If,cnt-1,newN) ;

%% Update plots zooming out
N                      = numel(S.dnum) ;
I0                     = 1 ;
If                     = N ;
handles.edit_I0.String = '1' ;
handles.edit_If.String = num2str(N) ;

guidata(hObject, handles);
update_plots(hObject, eventdata, handles) ;

% Update handles structure
guidata(hObject, handles);

end