
%% Spike rate using locfit with default parameters
display('To plot the spike rate for one trial using locfit, press enter');
pause
%
% Compute the fit
%
data=dsp2t(1).times;
fitm=locfit(data,'family','rate');
%
% Plot the histogram
%
figure;
subplot(211); 
[h,x]=hist(data,linspace(0,3,30));
bar(x,h/(x(2)-x(1)));
set(gca,'FontName','Times New Roman','Fontsize', 16);
xlim([0 3]);
xlabel('time s'); ylabel('Rate Hz');
%
% Plot the fit
%
subplot(212);
lfplot(fitm);
set(gca,'FontName','Times New Roman','Fontsize', 16);
xlabel('time s'); ylabel('Rate Hz');
title('Smoothed spike rate for 1 trial');
lfband(fitm);
xlim([0 3]);
position_figure;