function plotIntensity(DBS, I, totalI, tag, ax)

% plot patterns
if totalI
    I=cumulativeI(DBS);
end
surf(DBS.Intensity.X, DBS.Intensity.Y, I, ...
     'EdgeColor','none','FaceColor','interp','Parent',ax)
title(ax, tag,'FontSize',14)
view(ax,2) 
axis(ax,'equal')
xlabel(ax, 'X (mm)')
ylabel(ax, 'Y (mm)')
xlim(ax,[-DBS.Space.RangeXY/2 DBS.Space.RangeXY/2])
ylim(ax,[-DBS.Space.RangeXY/2 DBS.Space.RangeXY/2])
c=colorbar(ax);
set(get(c, 'xlabel'), 'string', 'Normalised intensity', 'rotation', 90);

colormap(ax, jet(20));

%---
function Ibeam=cumulativeI(DBS)

Ibeam=sum(DBS.Intensity.Ibeam,3);
%... normalise
if DBS.Shape.Normalise
    Ibeam=Ibeam/max(Ibeam(:));
end

