aboutsummaryrefslogtreecommitdiffstats
path: root/lab2/scripts/gensin.m
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2018-01-29 13:08:05 +0000
committerYann Herklotz <ymherklotz@gmail.com>2018-01-29 13:08:05 +0000
commitd04662418a3f747a965710ebf812e7aec96bae5b (patch)
tree426deb323f0ecda53d391884d192c4882eb4626b /lab2/scripts/gensin.m
parent8ae00d0644561e4211e0531b29ffff876c092f25 (diff)
downloadNoiseSilencer-d04662418a3f747a965710ebf812e7aec96bae5b.tar.gz
NoiseSilencer-d04662418a3f747a965710ebf812e7aec96bae5b.zip
[lab2] Adding screenshots
Diffstat (limited to 'lab2/scripts/gensin.m')
-rw-r--r--lab2/scripts/gensin.m23
1 files changed, 23 insertions, 0 deletions
diff --git a/lab2/scripts/gensin.m b/lab2/scripts/gensin.m
new file mode 100644
index 0000000..ae8b6d7
--- /dev/null
+++ b/lab2/scripts/gensin.m
@@ -0,0 +1,23 @@
+% Generates a discrete sine wave with the following properties
+
+% A: Amplitude
+% F0: frequency
+% fs: sampling frequency
+% theta: initial phase
+% nstart: first sample index
+% nend: last sample index
+function x = gensin(A, F0, fs, theta, nstart, nend)
+
+% zero the column vector to the right size
+fullSeries = zeros(nend-nstart+1, 1);
+
+% go through all the elements until the end
+for i = 1:nend
+ % apply the sine wave for every element
+ fullSeries(i) = A*sin(2*pi*F0*i/fs + theta);
+end
+
+% set the result to the window that was passed in by the user
+x = fullSeries(nstart:nend);
+
+end \ No newline at end of file