-
Notifications
You must be signed in to change notification settings - Fork 1
/
GenDrift.m
39 lines (34 loc) · 1.02 KB
/
GenDrift.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
function [drift] = GenDrift(Data,L)
% Generate Random values to define a random drift
% Argoments:
% - Data: number of data in the dataset
% - L: length of the signals
% Method: r = a + (b-a).*rand(N,1)
% to obtain random value
% between the interval [a b]
% Prealloc data
A = zeros(1,Data);
N = zeros(1,Data);
minDriftOffset = zeros(1,Data);
maxDriftOffset = zeros(1,Data);
drift = zeros(Data,L);
% Vaiable for random genreation of data - Values can be changed
% Amplitude range
aA = 0.1; bA = 0.8;
% Sinusoid period range
aN = 1; bN = 3;
% Slanted Line slope range
aMin = 0; bMin = 0.5;
aMax = 0.5; bMax = 3;
% Generate random values
for i = 1:Data
A(i) = aA + (bA-aA).*rand(1);
N(i) = aN + (bN-aN).*rand(1);
minDriftOffset(i) = aMin + (bMin-aMin).*rand(1);
maxDriftOffset(i) = aMax + (bMax-aMax).*rand(1);
X = linspace(0,2*pi,L);
cos_wave = A(i)*cos(X./N(i));
slantedLine = linspace(minDriftOffset(i),maxDriftOffset(i),L);
drift(i,:) = cos_wave + slantedLine;
end
end