LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

STFT Spectrogram - 50% Overlap

Solved!
Go to solution

Hello...

 

Your code with PSD its really working fine, but I still have a problem.

 

I used to perform the spectral analysis of my data using a Matlab routine, using specgram function of Matlab. But the problem was that this Matlab routine was not so flexible to handle file with different number of values. Because of this I am trying to use Labview to perform this analysis.

 

One problem that I am facing is that the absolute values are much different between Matlab routine with specgram function and Labview routine with PSD function. For example: if I take into consideration two frequency bands, one from 1 to 2 Hz, an another from 2.5 to 3 Hz. After perform a integration of the values em these bands (just to calculate the area of the spectrum) I got different absotule values comparing the Matlab Routine with specgram function and Labview routine with PSD function, but if these values are considered in normalized units (%), the results are exactly the same. I don't know what I need to change in the Labview code to achieve the same absolute results.

 

Attached its the Matlab routine to you take a look in the function that I used.

 

Thank you very much for your great attention

 

Dan07

Message Edited by dan07 on 01-29-2009 12:01 AM
0 Kudos
Message 11 of 36
(3,029 Views)

Hello,

 

Sorry but i'm little bit confused with your questions , you start with SFFT that returns a time-frequency plot/Array, telling you 

expect for a 2D array of 256*3 that is to say you want PSD analysys , then talking about spectrogram that is a time frequency response ???

I 'm a little bit lost , are you sure your project is not creating spectrogram using PSD with multiple overlaping windows...

 

They are not any more really dealing questions of labview but signal treatment :smileysurprised:

 

some links

http://vise.www.ecn.purdue.edu/VISE/ee438L/matlab/help/pdf/specgram.pdf

 

http://zone.ni.com/reference/en-XX/help/371361A-01/lvanls/stft_spectrogram_core/

 

http://forums.ni.com/ni/board/message?board.id=100&message.id=1088

 

@+

Tinnitus
CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
Message 12 of 36
(3,012 Views)

Hello....

 

Sorry for the consufed explanation that I made.

 

To make everything clear: I need to create a labview routine to do the same of the matlab routine that I sent attached in the last message. I need to perform spectral analysis of two signals that occur in the same time during around 900 seconds.

 

In the matlab routine I used the specgram using overlapping windows, and the routine its ready to process spreadsheet files with 3 columns: firts column its the time, second column its one signal and third column another signal, the whole series its 900 seconds long (the limitation of my matlab routine is that it does not handle files shorter or longer than 900 seconds). For each signal (column two and three), matlab routine will interpolate the 900 s series, generating a new interpolated series of 9001 points (dt=0.1). This interpolated series will be splitted in 34 segments of 512 points, overlaped by 50 %, and each one of these segments will be submitted to spectral analysis (using the specgram function). The final result will be two ascii files (one for signal of column two and another to signal on column three) with 34 columns, each column with the spectral analysis results for that segment.

 

The matlab code was not created by me, but I think that you are correct when said that the project its creating spectogram using PSD with multiple overlaping windows.

 

The only thing that I am sure is that I need to create a labview routine with same action of the matlab one's. The code to split the file its clear to me, using the for loop. But I need to know which operation will be placed inside the for loop and will be applied to each one of the segments. As I said before, my matlab routine its not so flexible but represents what I need to do. 

 

Thanks again for your attention, this project its very important to my job.

 

Dan07 

0 Kudos
Message 13 of 36
(3,014 Views)

Hello,

 

This is not exactly what is done with matlab code you sent or it miss stage!!

 columns extract and interpolation ok.

in this code spectgramm is calculated on all full signal pi and  fi that results B and C then there is no more work on but BxB*  and CxC*  ...

 

the following code just take part of pi and fi ( with overlap of 256) that give 34 part and make calculus on each bands, mean, std and other

may be is that you are trying to recreate ? info on each band ?

 

@+

Tinnitus

 

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 14 of 36
(2,995 Views)

hello,

 

tell if this is more or less  what you are looking for

 

@+

 

Tinnitus

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 15 of 36
(2,987 Views)

Hello...

 

The Matlab routine calculates the mean and stdv for each segment, but it also generates a ascii file for signal on column two and a ascii file for signal on column three, with 34 columns and 257 rows each, that are the spectral analysis results for each segment. This table with 34 columns and 257 rows I did not get with your code.

 

Attached its a zip file with a example file to be loaded into the matlab routine, and all the files that matlab generate saved as ascii files. Find attached also a file with instructions to run the matlab routine, just to you see how it works and if you want to use the file source.txt (in the zip file) to generate all the files with results again.

 

Just remember to rename the matlab routine to hrv.m

 

Thanks

 

Dan07

 

 

Message Edited by dan07 on 01-29-2009 10:44 AM
Download All
0 Kudos
Message 16 of 36
(2,983 Views)

Hello,

 

I have feeling you play with tools but you don't know exactly why and how!!!

 

just put 256 in time step 512 in frequency step, hanning with 512

 

and in stft array you recover a 256 or 257 (depend if you reject nyquist frequency(in time-frequencyconfig cluster) * 35 , just because sftf doesn't act exactly like spectgramm matlab function

 

to save array in file , this is another question

 

Best regards

 

Tinnitus

 

 

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 17 of 36
(2,977 Views)

Hello,

 

I've put 256 in incréments de temps,  512 in intervalles de fréquence, 512 in longueur of the window. WIth these settings I got a 257 * 36 Spectrogramme STFT {X}, as shown in "taille(s) 3"  indicator. But, why I got 36 and not 34?

 

Since that 8960 points splitted in segments of 512 points overlapped by 256, will result in 34 segments. 

 

0 - 512

256 - 768

512 - 1024

.....

 

Thanks and best regards

 

Dan07

0 Kudos
Message 18 of 36
(2,973 Views)

hello,

 

this due to centered windows, so use array palette to reject firt and last row

->(arraysubset) and select start=1 length=floor(length(x)/256)-1 or 34

 

@+

Tinnitus

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 19 of 36
(2,968 Views)

Hello...

 

Ok, I will reject the first and last row.

 

But since that I have 34 results for means and stdvs calculated from the segments spllited by the for loop, may I accept as true that after had rejected the first and last row and got 34 rows in the spectrogram, I can assume that the first row of the spectrogram had been generated by the same data which generated the first mean and stdev result. What I mean is, I need to match the means and stdvs results with the spectrogram results and say: "this first row of the spectrogram was generated by a certain piece of the data using spectrogram, and the mean and stdev of this piece of data its 345 and 12 (numbers just as examples).

 

Thanks

 

Dan07

0 Kudos
Message 20 of 36
(2,960 Views)