Prev: spectrogram
Next: mixed model anova
From: Martin on 8 May 2010 16:37 Hi everyone I need a help with 'spectrogram' function. It makes FFT of my signal and plots it with time and frequency on the axis and the magnitude of frequency showed with color. The frequency range of FFT algorithm depends on the sampling frequency. In my case the sampling frequency is very high (160 kHz), but as the result I focus just on the range 0-60 Hz. Can I modify spectrogram to compute the fft only up to 60 Hz? I can change the range in Axes properties but in this way I loose the information of magnitude (displayed with color) because I just cut a very small piece from wide frequency range Thank you for your help and tips. Martin Bruha
From: Wayne King on 8 May 2010 16:42 "Martin " <martin.bruha(a)gmail.com> wrote in message <hs4hih$bn6$1(a)fred.mathworks.com>... > Hi everyone > > I need a help with 'spectrogram' function. It makes FFT of my signal and plots it with time and frequency on the axis and the magnitude of frequency showed with color. > The frequency range of FFT algorithm depends on the sampling frequency. > In my case the sampling frequency is very high (160 kHz), but as the result I focus just on the range 0-60 Hz. Can I modify spectrogram to compute the fft only up to 60 Hz? > I can change the range in Axes properties but in this way I loose the information of magnitude (displayed with color) because I just cut a very small piece from wide frequency range > > Thank you for your help and tips. > > Martin Bruha Hi Martin, you can use the syntax [S,F,T]=spectrogram(x,window,noverlap,F,fs) See the documentation. You can specify a vector of frequencies,F, at which to compute the short-time Fourier transform. Also, you can always manipulate the colormap, or use caxis() so that you color your plot the way you wish. Hope that helps, Wayne
From: Haitham Tahbub on 8 May 2010 18:02 "Wayne King" <wmkingty(a)gmail.com> wrote in message <hs4ias$7a$1(a)fred.mathworks.com>... > "Martin " <martin.bruha(a)gmail.com> wrote in message <hs4hih$bn6$1(a)fred.mathworks.com>... > > Hi everyone > > > > I need a help with 'spectrogram' function. It makes FFT of my signal and plots it with time and frequency on the axis and the magnitude of frequency showed with color. > > The frequency range of FFT algorithm depends on the sampling frequency. > > In my case the sampling frequency is very high (160 kHz), but as the result I focus just on the range 0-60 Hz. Can I modify spectrogram to compute the fft only up to 60 Hz? > > I can change the range in Axes properties but in this way I loose the information of magnitude (displayed with color) because I just cut a very small piece from wide frequency range > > > > Thank you for your help and tips. > > > > Martin Bruha > > Hi Martin, you can use the syntax > > [S,F,T]=spectrogram(x,window,noverlap,F,fs) > > See the documentation. You can specify a vector of frequencies,F, at which to compute the short-time Fourier transform. > > Also, you can always manipulate the colormap, or use caxis() so that you color your plot the way you wish. > > Hope that helps, > Wayne Hi wayne .. I am trying to work with simulink to get the function of the spectrogram . so if i want to get the same dimensions that i am getting in this code : dr1 =specgram(y1,512,384,hann(512),256); so the result dr1 :- the size of (dr1) ans = 257 X 84 in the matlab code when performing this line of code . ..... how can i get the same dimensions from the simulink by using the SFFT block with a hanning window (wn) and with the block ( from wave file ) as inputs of the fft block , so i am getting the output dimension of the block as a 3D signal 256 X 1 X 84 . how can i get the same dimension as in the code to be 256 X 84??? Please help me if you can.? Regards Haitham
From: Martin on 9 May 2010 14:23 Hi Waine thanks for the tips, I will check it now. Maybe one more question: I get the diagram using spectrogram function and then in the options I choose to add a colorbar. I wonder why about 60% of the range in colorbar is negative (like -100...+60). The color represents the magnitude of certain frequency component at certain time. How can it be negative? Or is there something wrong in my point of view? Thanks again, Martin "Wayne King" <wmkingty(a)gmail.com> wrote in message <hs4ias$7a$1(a)fred.mathworks.com>... > "Martin " <martin.bruha(a)gmail.com> wrote in message <hs4hih$bn6$1(a)fred.mathworks.com>... > > Hi everyone > > > > I need a help with 'spectrogram' function. It makes FFT of my signal and plots it with time and frequency on the axis and the magnitude of frequency showed with color. > > The frequency range of FFT algorithm depends on the sampling frequency. > > In my case the sampling frequency is very high (160 kHz), but as the result I focus just on the range 0-60 Hz. Can I modify spectrogram to compute the fft only up to 60 Hz? > > I can change the range in Axes properties but in this way I loose the information of magnitude (displayed with color) because I just cut a very small piece from wide frequency range > > > > Thank you for your help and tips. > > > > Martin Bruha > > Hi Martin, you can use the syntax > > [S,F,T]=spectrogram(x,window,noverlap,F,fs) > > See the documentation. You can specify a vector of frequencies,F, at which to compute the short-time Fourier transform. > > Also, you can always manipulate the colormap, or use caxis() so that you color your plot the way you wish. > > Hope that helps, > Wayne
From: Wayne King on 9 May 2010 17:36
> "Wayne King" <wmkingty(a)gmail.com> wrote in message <hs4ias$7a$1(a)fred.mathworks.com>... > > "Martin " <martin.bruha(a)gmail.com> wrote in message <hs4hih$bn6$1(a)fred.mathworks.com>... > > > Hi everyone > > > > > > I need a help with 'spectrogram' function. It makes FFT of my signal and plots it with time and frequency on the axis and the magnitude of frequency showed with color. > > > The frequency range of FFT algorithm depends on the sampling frequency. > > > In my case the sampling frequency is very high (160 kHz), but as the result I focus just on the range 0-60 Hz. Can I modify spectrogram to compute the fft only up to 60 Hz? > > > I can change the range in Axes properties but in this way I loose the information of magnitude (displayed with color) because I just cut a very small piece from wide frequency range > > > > > > Thank you for your help and tips. > > > > > > Martin Bruha > > > > Hi Martin, you can use the syntax > > > > [S,F,T]=spectrogram(x,window,noverlap,F,fs) > > > > See the documentation. You can specify a vector of frequencies,F, at which to compute the short-time Fourier transform. > > > > Also, you can always manipulate the colormap, or use caxis() so that you color your plot the way you wish. > > > > Hope that helps, > > Wayne "Martin " <martin.bruha(a)gmail.com> wrote in message <hs6ui8$1em$1(a)fred.mathworks.com>... > Hi Waine > thanks for the tips, I will check it now. Maybe one more question: I get the diagram using spectrogram function and then in the options I choose to add a colorbar. I wonder why about 60% of the range in colorbar is negative (like -100...+60). The color represents the magnitude of certain frequency component at certain time. How can it be negative? Or is there something wrong in my point of view? > Thanks again, > Martin > Hi Martin, Are you plotting the spectrogram by calling the function with no output arguments? If so, you are seeing that the magnitudes are plotted in dB, in which case magnitudes less than 1 result in negative values. Wayne |