function example_2D()
    % Load example data
    %**********************************************************************
    % Data structure
    %**********************************************************************
    % - scans{i}.position: Position of the robot when taking the i'th scan
    %   - position(1): X coordinate of the robot
    %   - position(2): Y coordinate of the robot
    %   - position(3): Orientation of the robot
    % 
    % - scans{i}.scan: i'th scan taken b
    load 'scans_2D' scans;
    
    % Get number of scans.
    numScans = length(scans);
    
    % Initialize M and colors
    S = [];

    % Initialize graphic objects
    figure
    mainAx = axes;
    mapObj = plot(mainAx, nan,nan,'b.');
    axis(mainAx,'equal');
        
    % Iterate over each image taken with the RGB-D camera
    for scanID = 1:numScans
        % Load Template PC.
        T = scans{scanID}.scan;
        robotPos = scans{scanID}.position;
        
        % Calculate new cam position and update M
        S = PCMerge(S, T, robotPos); 

        % Display progress
        disp(['Scan ',num2str(scanID),' out of ', num2str(numScans)]);
        mapObj.XData = S(1,:);
        mapObj.YData = S(2,:);
        
        % Refresh interface
        refresh;
        drawnow;
    end
end

function pcObj = displayPC_RGB(xyz, colormap, pcObj, targetAx, titleStr)
    ptCloud = pointCloud(xyz,'Color',colormap);
    if isempty(pcObj)   
        pcObj = pcshow(ptCloud,'Parent', targetAx);      
        title(targetAx,titleStr);
    else
        try
            pcObj.XLim = ptCloud.XLimits;
            pcObj.YLim = ptCloud.YLimits;
            pcObj.ZLim = ptCloud.ZLimits;
            pcObj.Children.XData = xyz(:,1);
            pcObj.Children.YData = xyz(:,2);
            pcObj.Children.ZData = xyz(:,3);
            pcObj.Children.CData = colormap;
        catch
        end
    end
end