diff options
author | Julian T <julian@jtle.dk> | 2021-01-11 17:19:56 +0100 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-01-11 17:19:56 +0100 |
commit | 8ead771aafe22c7cdf30436da9c6e2614831f1ee (patch) | |
tree | a75eff47579354a45e9d76c50672416a14986a19 /sem5/sig/eksamnen/fir-plot.m | |
parent | ccf8359ed3a061cdff335b39ddb27a36b296e1d9 (diff) |
Added signal processing notes and assignments
Diffstat (limited to 'sem5/sig/eksamnen/fir-plot.m')
-rw-r--r-- | sem5/sig/eksamnen/fir-plot.m | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/sem5/sig/eksamnen/fir-plot.m b/sem5/sig/eksamnen/fir-plot.m new file mode 100644 index 0000000..3148b9b --- /dev/null +++ b/sem5/sig/eksamnen/fir-plot.m @@ -0,0 +1,37 @@ +clear + +M = 28; + +for i=0:999, + omega(i+1) = pi * i / 999; +end; + + +for i=0:999, + sum_t = 0; + sum_b = 0; + + for k=1:M/2, + % h får altid M/2 så det kan optimeres ud. + h = ((sin((pi/4) * k)) / (pi * k)); + + a = 2 * h; + % Hamming: + a = a * (0.54 - 0.46 * cos( 2 * pi * (k + (M/2)) / (M))); + + sum_t = sum_t + a * cos(k * omega(i+1)); + sum_b = sum_b + a; + end; + + % Når k=0 + sum_t = sum_t + 0.25; + sum_b = sum_b + 0.25; + + amp(i+1) = sum_t / sum_b; + +end; + +plot(omega, 20 * log10(abs(amp)), 3/16 * pi, -1, "+", 3/8 * pi, -10, "+") +grid; +xlabel("Frequency"); +ylabel("Amplitude [dB]");
\ No newline at end of file |