function [h,xm,xs]=plotUnc(x,x0,dx)
% plotUnc <Plot Uncertainties of random variable x>
% Usage:: h=plotUnc(x,x0[mean(x)],dx[std(x)])
%
% Plot uncertainties of random variable x with with given mean x0 and std dx

% revision history:
% 02/24/2025 Mark D. Shattuck <mds> plotUnc.m

%% Parse Input
if(~exist('x0','var') || isempty(x0))
	x0=mean(x);
end

if(~exist('dx','var') || isempty(dx))
	dx=std(x);
end

%% Main
N=length(x);  % number of points
n=1:N;        % point list for plot
xm=mean(x);   % measured mean
xs=std(x);    % measured std

%% Make plot
h=plot(n,x,...                        % random variable 
     [1 N],xm*[1 1],'r',...           % measured mean
     [1 N],(xm+xs)*[1 1],'r',...      % measured +std
     [1 N],(xm-xs)*[1 1],'r',...      % measured -std 
     [1 N],x0*[1 1],'k--',...         % ideal mean
     [1 N],(x0+dx)*[1 1],'k--',...    % ideal +std
     [1 N],(x0-dx)*[1 1],'k--');      % ideal -std
