WHS MatLab Mass Spec Demo

Mass Spec Program

Updated 08/12/04

% Mass Spec Simulation for 
% Atomic Abundances and isotopes

load atom.dat;

% Load atomic numbers
atno=atom(:,1);

% Load atomic masses
mass=atom(:,3);

% Load percent abundances
perc=atom(:,4);

% Ask which element
x=input ('Enter atomic number of element to be graphed ');

i = find(atno==x);
sz=size(i);

% The following set of commands creates two matrices
% massp will contain the triplicate entries of the mass values
% percp will contain single entries of the percentages bracketed by zeros
% Plotting these two results in the line spectrum

n=3*sz(1,1);
mass1=reshape(mass(i),1,sz(1,1));
z1=[1;1;1];
mass2=z1*mass1;
massp=reshape(mass2,1,n);

perc1=reshape(perc(i),1,sz(1,1));
z2=[0;1;0];
perc2=z2*perc1;
percp=reshape(perc2,1,n);

% Plot mass spec for element
xleft=min(mass(i))-5;
xrght=max(mass(i))+5;

plot(massp,percp);

axis([xleft xrght 0 100]);
title (['Mass Spectrum for Atomic No. ',int2str(x)]);
xlabel ('Mass of isotope');
ylabel ('Percent abundance');

- - - - - - - - - - - - - - - - - -

And sample output: