[plotting] movie example
This commit is contained in:
parent
14d29efdb4
commit
b9b791f315
54
plotting/code/movie_example.m
Normal file
54
plotting/code/movie_example.m
Normal file
@ -0,0 +1,54 @@
|
||||
clear all
|
||||
close all
|
||||
max_frames = 500;
|
||||
|
||||
f_x = 1;
|
||||
f_y = 1.5;
|
||||
dt = 2*pi/500;
|
||||
|
||||
f = figure();
|
||||
set(f, 'visible', 'off');
|
||||
set(f, 'PaperUnits', 'centimeter', 'PaperSize', [2.5, 2.5], ...
|
||||
'PaperPosition', [0, 0, 2.5, 2.5], 'Color', 'white')
|
||||
|
||||
writer = VideoWriter('../lecture/images/lissajous.mp4', 'MPEG-4');
|
||||
writer.FrameRate = 25;
|
||||
writer.Quality = 50;
|
||||
|
||||
open(writer);
|
||||
for i = 1:max_frames
|
||||
x = sin(f_x * 2 * pi * dt * i);
|
||||
y = sin(f_y * 2 * pi * dt * i);
|
||||
scatter(x, y, 30, 'r', 'filled');
|
||||
xlim([-1.05, 1.05])
|
||||
xticks([-1., 0., 1.])
|
||||
ylim([-1.05, 1.05])
|
||||
yticks([-1., 0., 1.])
|
||||
xlabel('x')
|
||||
ylabel('y')
|
||||
drawnow;
|
||||
frame = getframe(f);
|
||||
writeVideo(writer, frame);
|
||||
end
|
||||
close(writer)
|
||||
|
||||
x_positions = zeros(max_frames, 1);
|
||||
y_positions = zeros(max_frames, 1);
|
||||
for i = 1:max_frames
|
||||
x_positions(i) = sin(f_x * 2 * pi * dt * i);
|
||||
y_positions(i) = sin(f_y * 2 * pi * dt * i);
|
||||
end
|
||||
|
||||
f = figure();
|
||||
set(f, 'PaperUnits', 'centimeter', 'PaperSize', [5, 5], ...
|
||||
'PaperPosition', [0, 0, 5, 5], 'Color', 'white')
|
||||
|
||||
scatter(x_positions, y_positions, 10, 'r', 'filled');
|
||||
xlim([-1.05, 1.05])
|
||||
xticks([-1., 0., 1.])
|
||||
ylim([-1.05, 1.05])
|
||||
yticks([-1., 0., 1.])
|
||||
xlabel('x')
|
||||
ylabel('y')
|
||||
|
||||
saveas(f, '../lecture/images/lissajous.png')
|
BIN
plotting/lecture/images/lissajous.png
Normal file
BIN
plotting/lecture/images/lissajous.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.8 KiB |
@ -32,8 +32,7 @@ locking, respectively.
|
||||
i.e. the fish's field The data is sampled with 20\,kHz and the spike
|
||||
times are given in seconds.
|
||||
\begin{parts}
|
||||
\part Plot an average of the single EOD cylces of each fish
|
||||
together with an respective PSTH.
|
||||
\part Plot the average EOD waveform of each fish together with an respective PSTH.
|
||||
\part Implement a function that estimates the vector strength
|
||||
between the \textit{eod} and the spikes.
|
||||
\part Create a polar plot that shows the timing of the spikes
|
||||
|
Reference in New Issue
Block a user