function ErrorPlot(X,Xerror,k,titlestring,ylabelstring)
% function ErrorPlot(X,Xerror,k,titlestring,ylabelstring)
%
% Function to plot a quantity (X) along with its + an - error bars (Xerror)
% X is a vector of computed values
% Xerror is the same size error vector associated with the computed X
% k is multiplier on the error bars
% k=1 for absolute errors
% k=2, generally, for root-mean square (Gaussian) errors

if isempty(k); k=1; end % make sure if k is always set to something

ind=1:length(X);
plot(ind,X,'kx',ind,X+k*Xerror,'rv',ind,X-k*Xerror,'r^')
title(titlestring)
ylabel(ylabelstring)
xlabel('Data point number')
string1=[ylabelstring,'+',num2str(k),'error'];
string2=[ylabelstring,'-',num2str(k),'error'];
legend(ylabelstring,string1,string2)

hold on
plot([ind;ind],[X-k*Xerror; X+k*Xerror],'k-')
hold off
