Polished function to look like a heart beat kinda
This commit is contained in:
parent
03f7c5f0e5
commit
44d53234e9
@ -19,6 +19,7 @@ function x = generate_heart_monitor(amplitude, frequency, phase, fs, duration, d
|
|||||||
n = fs * duration; % number of samples (length of matrix)
|
n = fs * duration; % number of samples (length of matrix)
|
||||||
dt = 1 / fs; % sampling period: time between two sample points
|
dt = 1 / fs; % sampling period: time between two sample points
|
||||||
|
|
||||||
|
|
||||||
% initialize a one dimensional zero matrix to be populated
|
% initialize a one dimensional zero matrix to be populated
|
||||||
x = zeros(1, n);
|
x = zeros(1, n);
|
||||||
|
|
||||||
@ -27,16 +28,15 @@ function x = generate_heart_monitor(amplitude, frequency, phase, fs, duration, d
|
|||||||
t = i * dt; % time at the i'th sample
|
t = i * dt; % time at the i'th sample
|
||||||
st = mod(frequency * t - phase, 1);
|
st = mod(frequency * t - phase, 1);
|
||||||
|
|
||||||
if (duty-0.1 < st && st < duty)
|
if (duty-0.25 < st && st < duty)
|
||||||
slope = amplitude / duty;
|
slope = amplitude / duty;
|
||||||
intercept = -0.5 * amplitude;
|
intercept = -0.5 * amplitude;
|
||||||
x(i) = slope * st + intercept;
|
x(i) = slope * st + intercept;
|
||||||
elseif (duty < st && st < duty+0.1)
|
elseif (duty < st && st < duty+0.25)
|
||||||
slope = -amplitude / duty;
|
slope = amplitude / duty;
|
||||||
intercept = amplitude * (duty/(1-duty) + 0.5);
|
intercept = -amplitude;
|
||||||
x(i) = slope * st + intercept;
|
x(i) = slope * st + (1.5 * intercept);
|
||||||
else
|
else
|
||||||
x(i) = 0;
|
x(i) = 0;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user