-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmake_movie_from_signal.m
41 lines (33 loc) · 1002 Bytes
/
make_movie_from_signal.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
%% get data
fileName='example';
% reading actual video:
% vidObj = VideoReader([fileName '.avi']);
% reading from file
% load([fileName '.mat'])
% generating example data: chirp
samplingRate=1000;
Time = 0:1/samplingRate:2;
data = chirp(Time,100,1,200,'q');
figure;
spectrogram(data,128,120,128,1E3,'yaxis')
title('Quadratic chirp')
%% Create video object and Initialize parameters
vidObj = VideoWriter([fileName '.avi']);
vidObj.FrameRate=25;
open(vidObj);
%% add frames
set(0,'DefaultAxesColor','black')
figure('Color','black','Visible', 'off');
for framNum=1:vidObj.FrameRate*10 %10 secondes
%add an image to the movie:
% f = im2frame(Img);
% writeVideo(aviobj,f);
%Or plot vector, then Add to Movie:
plot(data((samplingRate/vidObj.FrameRate)*(framNum-1)+1:(samplingRate/vidObj.FrameRate)*(framNum)+1));
ylim([min(data(1:samplingRate*10+1)) max(data(1:samplingRate*10+1))]);
% axis('tight');box off;
f = getframe;
writeVideo(vidObj,f);
end
%% close movie
close(vidObj);