Trouble understanding why the spectrum of my signal is at maximum power all frequencies

6 views (last 30 days)
So I'm playing around with spectrograms and I'm trying to output a spectrogram where frequency actually changes with time so I've written this little bit of code:
fs = 250;
t = 0:1/fs:2;
temp = vco(sin(2*pi*t),5,fs);
temp1 = vco(sin(2*pi*t),5,fs);
temp2 = vco(sin(2*pi*t),5,fs);
temp3 = vco(sin(2*pi*t),40,fs);
temp4 = vco(sin(2*pi*t),45,fs);
temp5 = vco(sin(2*pi*t),90,fs);
temp6 = vco(sin(2*pi*t),90,fs);
x = [temp temp1 temp2 temp3 temp4 temp5 temp6];
segment_length = length(temp);
length(x);
winSize = segment_length;
fftSize = winSize;
overlap = floor(winSize/2);
[S,F,T,P] = spectrogram(x,winSize,overlap,fftSize,fs);
spectrogram(x,winSize,overlap,fftSize,fs)
The idea is that each 'temp' is a segment of the overall signal x. After three temps, the frequency continues to change and I'm hoping that I've used spectrogram correctly as I've used the length of each segment as the window and fftSize is equal to window length. However, my spectrogram output is this:
It seems that at 4 seconds it's at temp 2 which should only have power in the 40 - 80 Hz range whilst it does have that, it also seems to retain the frequencies of the first three segments and I'm not entirely sure why.
If I look at the Signal Analyzer App:
My x signal looks right to me as the frequency is changing as it should but I don't quite understand why I'm still having the same problem in the spectrogram, once it gets to 900-1000 samples the waveform changes representing a frequency of 40 Hz but for some reason in the spectrogram I'm still retaining all the information of the previous segment's frequency.

Answers (0)

Categories

Find more on Time-Frequency Analysis in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!