display('To compute spike rate for this trial with a lower bandwidth, press return');
pause
%
% Compute the fit
%
nn=0.3;  % set the bandwidth
data=dsp2t(1).times;
fitm=locfit(data,'family','rate','nn',nn);
%
% Plot the histogram
%
figure;
subplot(211); 
[h,x]=hist(data,linspace(0,3,30));
bar(x,h/(x(2)-x(1)));
xlim([0 3]);
set(gca,'FontName','Times New Roman','Fontsize', 16);
xlabel('time s'); ylabel('Rate Hz');
%
% Plot the fit
%
subplot(212);
lfplot(fitm); 
xlim([0 3]);
set(gca,'FontName','Times New Roman','Fontsize', 16);
xlabel('time s'); ylabel('Rate Hz');
lfband(fitm,'band','g');
title('Rate estimate with smaller bandwidth');
position_figure