[pointprocesses] fixed exercises

This commit is contained in:
Jan Benda 2021-01-18 19:09:56 +01:00
parent 6a643cd347
commit 753d756409
5 changed files with 3 additions and 12 deletions

View File

@ -6,16 +6,12 @@ function rasterplot(spikes, tmax)
% Arguments: % Arguments:
% spikes: a cell array of vectors of spike times in seconds % spikes: a cell array of vectors of spike times in seconds
% tmax: plot spike raster up to tmax seconds % tmax: plot spike raster up to tmax seconds
in_msecs = tmax < 1.5
spiketimes = []; spiketimes = [];
trials = []; trials = [];
ntrials = length(spikes); ntrials = length(spikes);
for k = 1:ntrials for k = 1:ntrials
times = spikes{k}; times = spikes{k};
times = times(times<tmax); times = times(times<tmax);
if in_msecs
times = 1000.0*times; % conversion to ms
end
% (x,y) pairs for start and stop of stroke % (x,y) pairs for start and stop of stroke
% plus nan separating strokes: % plus nan separating strokes:
spiketimes = [spiketimes, ... spiketimes = [spiketimes, ...
@ -30,13 +26,8 @@ function rasterplot(spikes, tmax)
trials = trials(:); trials = trials(:);
% plotting this is lightning fast: % plotting this is lightning fast:
plot(spiketimes, trials, 'k') plot(spiketimes, trials, 'k')
if in_msecs xlabel('Time [s]');
xlabel('Time [ms]'); xlim([0.0 tmax]);
xlim([0.0 1000.0*tmax]);
else
xlabel('Time [s]');
xlim([0.0 tmax]);
end
ylabel('Trials'); ylabel('Trials');
ylim([0.3 ntrials+0.7]); ylim([0.3 ntrials+0.7]);
end end

View File

@ -55,7 +55,7 @@
\end{solution} \end{solution}
\newsolutionpage \newsolutionpage
\part Write a function that illustrated the spike times of the \part Write a function that displays the spike times of the
first $t_{max}$ seconds in a raster plot. Each spike train is one first $t_{max}$ seconds in a raster plot. Each spike train is one
row in the raster plot. Each spike is a vertical line at the time row in the raster plot. Each spike is a vertical line at the time
of the spike. When appropriate, the function should use milliseconds of the spike. When appropriate, the function should use milliseconds