I hope this will be fun for you to investigate and play with. Weird stuff happens. If weird stuff doesn't happen for you, then maybe my version of MATLAB (R2013a) is to blame.
I want to make a spectrogram of a noisy signal. Due to the signal's complexity, I've been messing around with a matlab example to understand how the inputs affect the output and what I expect to happen based on the help info vs. what I see actually plotted. This is the example (I added the 'yaxis' bit):
title('Quadratic Chirp: start at 100Hz and cross 200Hz at t=1sec');
I can tell, then, that they're using the form "spectrogram(X,WINDOW,NOVERLAP,NFFT,Fs,FREQLOCATION)."
So my understanding is that the 2nd argument is the number of time-axis segments to split the data into, 3rd is not super clear actually but the default is 50%. 50% of, I initially assumed, the adjacent two segments. The later statement of "NOVERLAP is the number of samples each segment of X overlaps." Ok, well in the default case of 8 segments and 50% of the samples, how can you make 8 segments when each segment is supposed to have 50% of the samples in it?? And why does it show 7 segments? This will show you what I mean:
Then lets decide we want 128 segments like they did, and we'll just be ok with the default NOVERLAP. Well, plot that and you'll see 29 segments, which isn't 50% of anything I can see.
Now put NOVERLAP to 20, and we get 17 segments. Change it to 5 and you'll get 15! Plot the original again, then lets look at what happens when we double the number of segments and bump the NOVERLAP a bit:
That doesn't look right! Maybe what I thought about NFFT was unclear. Lets double that...nope...at least that seems to behave properly. That's the number of segments the sample frequency spectrum is broken in to. Just for fun you can defy logic one last time with this:
How am I supposed to select the appropriate values for this function? Is there something wrong with it? For my real case I'll have a sampling frequency of 72 kHz and will have applied a zero-phase Butterworth low pass filter with cutoff at about 7 kHz.