function plotdataprofiles(A,B,C,E,X,Y,M,D,a,dr,T,dt,RadialDist,t0,count)
% usage: plotdataprofiles(A,B,C,E,X,Y,M,D,a,dr,T,dt,P,RadialDist,t0,count)
% description: plots exact radial proflle N(r,t0) and the approximate
% profiles obtained with p = 0.1, 0.5, 1.0.  These are hard-wired into
% the routine, but easily changed.  No error checking.

% for predictability...unrem the next line
rand('seed',2);
pr = [1,0.5,0.1]; % first probability must be 1
lenpr = length(pr);
timenodes = linspace(0,dt*T,T+1);
Tndx = find(t0<timenodes,1)-1;
% find max radius
radmax = max([norm([X,Y]-[A,C]),norm([X,Y]-[A,E]), ...
        norm([X,Y]-[B,C]),norm([X,Y]-[B,E])]);
radii = ceil(radmax/dr);
spacenodes = linspace(0,dr*radii,radii+1);
spacepoints = linspace(dr/2,dr*(radii-0.5),radii);
colors = 'rgbcmyk'; % must be at least size of pr...put black last
% set up graph for comparison of approximate and exact profiles
figure
grid,hold on
xlabel('Radius');
ylabel('Function values')
% plot the exact profile
plot(spacepoints,Nsoln(spacepoints,t0,M,D,a),strcat('-',colors(end)),...
  'LineWidth',2)
% create and graph profiles for first probability of 1
P = pr(1);
events = RadSim(A,B,C,E,X,Y,M,D,a,dr,T,dt,P,RadialDist);
cumulprofile = RadialProfile(events,X,Y,spacenodes,timenodes(Tndx),timenodes(Tndx+1));
cumulprofile = cumulprofile./(pi*dt*dr*(2*spacenodes+dr));
cumulprofile = cumulprofile(1:end-1);
plot(spacepoints,cumulprofile,strcat('--',colors(1)),'LineWidth',2)
% plot the profiles with probability less than 1
for ii = 2:lenpr
  P = pr(ii);
  cumulprofile = zeros(size(spacenodes));
  % accumulate profile samples
  for jj = 1:count
    events = RadSim(A,B,C,E,X,Y,M,D,a,dr,T,dt,P,RadialDist);
    profile = RadialProfile(events,X,Y,spacenodes,timenodes(Tndx),timenodes(Tndx+1));
    cumulprofile = cumulprofile + profile;
  end
  cumulprofile = cumulprofile./(count*pi*dt*dr*(2*spacenodes+dr));
  cumulprofile = cumulprofile(1:end-1);
  plot(spacepoints,cumulprofile,strcat('-',colors(ii)),'LineWidth',2)
end
% legend must be adapted to size of pr
legend(strcat('Profile of N(r,',num2str(t0),')'),'Computed profile, p = 1',...
  'Computed profile, p = 0.5','Computed profile, p = 0.1')
end

