function viewrms
if(~exist('dcinj.Xemit.001','file') || ~exist('dcinj.Yemit.001','file') || ~exist('dcinj.Zemit.001','file'))
    error('cannot find files. have you run Astra?')
end

X = load('dcinj.Xemit.001');
Z = load('dcinj.Zemit.001');

if (isempty(findobj('Tag','RMS')))
   scrsz = get(0,'ScreenSize');
   figure('Position',[12 1 scrsz(3)/1.2 scrsz(4)/1.2], 'Tag', 'RMS', 'Name', 'viewrms');
else
    figure(findobj('Tag', 'RMS'));
end

subplot(2,2,1)
plot(X(:,1),X(:,4),'-r');
xlabel('position (m)');
ylabel('x rms (mm)');
subplot(2,2,2)
plot(X(:,1),X(:,6),'-r');
xlabel('position (m)');
ylabel('emittance rms (mm-mrad)');
subplot(2,2,3)
plot(Z(:,1),Z(:,4),'-b');
xlabel('position (m)');
ylabel('z rms (mm)');
subplot(2,2,4)
plot(Z(:,1),Z(:,3),'-b');
xlabel('position (m)');
ylabel('K.E. (MeV)');
