From: JAMES AN on
Hi i am relatively new to Matlab and i use the spectrogram function to analyze a wav file. I do get a graph out of it, and i save the time,frequency and intensity into 3 vectors. How do i determine the local maximin(greatest magnitude) within a specific range of time(say from 0-100 time units).

Thx alot
From: Wayne King on
"JAMES AN" <jamesanse(a)gmail.com> wrote in message <hurea8$afp$1(a)fred.mathworks.com>...
> Hi i am relatively new to Matlab and i use the spectrogram function to analyze a wav file. I do get a graph out of it, and i save the time,frequency and intensity into 3 vectors. How do i determine the local maximin(greatest magnitude) within a specific range of time(say from 0-100 time units).
>
> Thx alot

Hi James, it depends on what you mean by "time units". Usually the windows in the spectrogram overlap. For example, for the following:

t = 0:0.001:2;
x = chirp(t,0,1,150);
[S,f,t] = spectrogram(x,256,250,[],1000);

You have a window length of 256, so you are computing spectral estimates for (256*.001) second segments of the signal. But, you have an overlap of 250 samples, so the difference between elements of the time vector t will be 0.006 (6*1000). Therefore, the first two columns of S contain frequency information over a time interval of (262*.001) seconds--the first column from [0,0.256] and the second column from [0.006,0.262].
In other words, there is a lot of redundancy in covering the duration of the signal. You can determine the number of columns in S that cover your time interval of interest and look at the maximum absolute value over those columns of S. Of course, if you wanted to, you can set the overlap to zero, and then each column is an estimate of the spectrum of a segment of the signal that is equal to the window length times the sampling interval (but that makes for a very blocky-looking spectrogram).

Hope that helps,
Wayne