update_plots.m 1.53 KB
function update_plots(hObject, eventdata, handles)

global S

I0    = str2num(handles.edit_I0.String);
If    = str2num(handles.edit_If.String);

% update track plot
axes(handles.ax_track) ;
plot(S.lon(I0:If),S.lat(I0:If),'b',S.lon(I0:If),S.lat(I0:If),'ko')

%% update aux  plot
blah     = get(handles.grp_aux_data,'SelectedObject') ;
whatever = get(blah,'String') ;

switch whatever
    case 'Speed'
        axes(handles.ax_aux_data);
        try delete(handles.aux_line) ; catch ; end
        
        [~,~,spd,~] = llt2spd(S.lon(I0:If),S.lat(I0:If),S.dnum(I0:If)) ;
        handles.aux_line = plot(I0:If,spd,'k') ;
        xlim([I0 If])
        xlabel('Index')
        ylabel('Speed (m/s)')
    case 'Time'
        axes(handles.ax_aux_data);
        try delete(handles.aux_line) ; catch ; end
        handles.aux_line = plot(I0:If,S.dnum(I0:If),'k') ;
        xlim([I0 If])
        xlabel('Index')
        ylabel('Time (mm/dd)')
        datetick('y','mm/dd') ;
    case 'Distance'
        axes(handles.ax_aux_data);
        try delete(handles.aux_line) ; catch ; end
        dist = [0 ; m_lldist(S.lon(I0:If),S.lat(I0:If))] ;
        handles.aux_line = plot(I0:If,dist,'k') ;
        xlim([I0 If])
        xlabel('Index')
        ylabel('Distance (km)')
    case 'None'
        axes(handles.ax_aux_data);
        XL = handles.ax_aux_data.XLim;
        YL = handles.ax_aux_data.YLim;
        try delete(handles.aux_line) ; catch ; end
        handles.ax_aux_data.XLim = XL ;
        xlabel('Index')
end

% Update handles structure
guidata(hObject, handles);

end