-
Notifications
You must be signed in to change notification settings - Fork 0
/
myUCO.m
34 lines (31 loc) · 740 Bytes
/
myUCO.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
function u = myUCO(t, ucoDuration, restDuration)
% myUCO generates a periodic square wave.
% The first UCO is set at t=0.
%
% INPUT:
% t: time vector (s).
% ucoDuration: duration (s).
% restDuration: rest duration, between two UCOs (s).
%
% OUTPUT:
% u: size(t) vector (it is 1 when the UCO is present).
%
% EXAMPLE:
% t = 0:1/1000:10*60; % (s).
% ucoDuration = 60; % (s).
% restDuration = 30; % (s).
% u = myUCO(t, ucoDuration, restDuration);
% plot(t, u);
% xlabel('Time (s)');
% ylabel('Amplitude');
% title('UCO');
% ylim([-0.5, 1.5]);
%
% VERSION:
% 1.0.0 First release.
%
% LAST UPDATE:
% 02/09/2019
u = zeros(size(t));
u((t >= 0) & (mod(t, ucoDuration + restDuration) < ucoDuration)) = 1;
end