function [handleTimeDivergenceToGps, handleLegend] = plotTimeDivergenceToGps(pAxesHandle, pTrajectory) %PLOTTIMEDIVERGENCETOGPS Summary of this function goes here % Detailed explanation goes here %% Setup return variables handleTimeDivergenceToGps = struct(); %% Get required data fnames = fieldnames(pTrajectory.timeDivergenceToGps); legendText = {}; %% Clear axes cla(pAxesHandle); %% Plot data hold(pAxesHandle, 'on'); counter = 1; for i = 1:length(fnames) if any(strcmp(fnames{i}, {'latitude', 'longitude', 'date'})) continue; end current = pTrajectory.timeDivergenceToGps.(fnames{i}); if isempty(current) continue; end x = current(:, 1); y = current(:, 2); handleTimeDivergenceToGps.(fnames{i}) = plot(pAxesHandle, x, y, '.-'); legendText{counter} = fnames{i}; counter = counter + 1; end hold(pAxesHandle, 'off'); %% Setup legend handleLegend = legend(pAxesHandle, legendText, 'Location', 'best'); end