function [handleResiduals, handleLegend] = plotResiduals(pAxesHandle, pTrajectory)
%CALCULATERESIDUALS Summary of this function goes here
%   Detailed explanation goes here

%% Setup return variables
handleResiduals = struct();

%% Get required data
residuals = pTrajectory.residuals;
soundsources = fieldnames(residuals);
rafosDate = pTrajectory.date;

%% Clear axes
cla(pAxesHandle);

%% Plot data
legendText = {};
hold(pAxesHandle, 'on');
for i = 1:length(soundsources)
    handleResiduals.(soundsources{i}) = plot(pAxesHandle, rafosDate, residuals.(soundsources{i}), '.-');
    legendText{i} = soundsources{i};
end
hold(pAxesHandle, 'off');

%% Setup legend
handleLegend = legend(pAxesHandle, legendText);

end

