-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.m
More file actions
50 lines (31 loc) · 1.14 KB
/
Copy pathrun.m
File metadata and controls
50 lines (31 loc) · 1.14 KB
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
38
39
40
41
42
43
44
45
46
47
%load('dsp_lab1_dat.mat');
M = 2^12;
Fs = 44100;
length = 2;
freq = 500;
disp(length*Fs/M);
dBmin = -60;
fMax = 1500;
signal = sin(linspace(0, 2*pi*freq*length, Fs*length)) + sin(linspace(0, 2*pi*freq*length*2, Fs*length));
rect = ones(1, M);
hannW = window(@hann, M);
%plot the example of spectral leakage & compare to hann window
%plot the effects of window size -> increased frequency resolution with
%both windows and decreased temporal resolution
%number of possible freq components proportional to the frameSize
%plot the effects of overlap -> temporal resolution, whilst allowing freq.
%resolution of lower window sizes -> may need a better example
t = linspace(0, length, Fs*length);
freq1 = 500;
freq2 = 1000;
f = linspace(freq1, freq2, length*Fs);
risingSine = sin(2*pi*cumsum(f)/Fs);
vcoSine = vco(sin(2*pi*0:1/Fs:length), [freq1 freq2], Fs);
figure
spect = spectrogramPSD(risingSine, Fs, hannW, fMax, dBmin, 0);
figure
spectrogramPSD(vcoSine, Fs, hannW, fMax, dBmin, 0.5);
figure
spectrogramPSD(vcoSine, Fs, hannW, fMax, dBmin, 0);
%if overlap too large -> unwanted freq. from prev/next segment ->
%incacurate time-domain representation