LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

STFT in overlapped segments

Hello...

My problem is:

I need to perform STFT analysis on a ascii file with 9001 values. The series is sampled in 10 Hz and should be segmented in 34 segments of 512 points each, overlapped by 256 points. Each one of these segments should be analyzed by STFT and the final result should be a ascii file with 34 columns (one column for each segment), 257 rows (512/2 + 1), and the spectra should show frequency until 5 Hz (10/2 = 5 Hz). The "Hanning Window" should be used.

The results aspects mentioned above are based on some criteria that I had fixed based on  researches.

I don't know how to set up the STFT vi to perform exactly these operations on my series. I don't no if STFT vi can handle with overlapped series, so I created a simple "for loop" to create the overlapped segments.

Attached is the VI with the initial code that I was working on, and one data example in ascii format.


Thanks

Dan07


Message Edited by dan07 on 06-18-2008 03:11 AM

Message Edited by dan07 on 06-18-2008 03:12 AM
Download All
0 Kudos
Message 1 of 8
(3,451 Views)
Anyone has a suggestion how to solve my problem?


Thanks in advance

Dan07
0 Kudos
Message 2 of 8
(3,427 Views)

You should be able to use a for loop.

Do 34 times

   Get array subset from i*256 to i*256+512

   do FFT on subset

   autoindex out the fft of the loop.

you will be left with 34 ffts that represent your STFT.

 

Paul

 

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 8
(3,418 Views)
Hello falkpl...

thanks for attention

I tried to do what you said but I am still don't getting the expected result. After the FFT Power Spectral Density analysis of my 34 segments, I expected to get a array (and later a ascii file), with 257 rows and 34 columns.

I expect 257 values (one each row) because in FFT analysis the number  of values cames from: ((number of elements of segment/2)+1).

Each one of the columns should represent the FFT analysis of each segment.

Attached is the VI that I modified and a example data file do load in.

Thanks for help

Dan07
Download All
0 Kudos
Message 4 of 8
(3,396 Views)

I think you were very close.  See the modifier stft.  You had an array of waveforms (freq vs time) you unbundle the Y data to get a 2d array of FFT amplitudes.  See the attached modified vi.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 5 of 8
(3,368 Views)
Hello falkpl... thanks for attention...

I performed some modifications in the VI and now I am getting the results like I expected, but I still have some questions.

After load the DATA.txt file into the VI, it generates a file that has 34 columns (as expected) but has 256 lines, and not 257 (512/2 + 1), do you know why?

The other issue concerns the results range. I used to use specgram function of Matlab to perform FFT analysis. When I compared the results obtained from Matlab with results from this VI, I observed that the values from VI are 1000 fold lower than data from Matlab, but the numbers represent the same thing because I splitted the 256 series of numbers into 3 or 4 ranges (from line 1 until 29, form line 30 until 90..............) to obtain the results in specific frequency ranges, and the normalized values (%) from the VI and from Matlab are identical. The only difference is on the absolute values that are 1000 fold lower in VI. Do you know why?

Attached is the VI and a DATA file to be loaded in.

Thanks

Dan07
Download All
0 Kudos
Message 6 of 8
(3,313 Views)

Most likely the difference is that you are not returning the results in dB (boolean input) as for the 2/n+1 I thought that it returns 2/n but I am not sure if I am right.  One code improvement would be to use the array size to determine the 34 and 256 values instead of using constants.  Your algorithm would be more flexable to handle diferent input lengths for the stft.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 7 of 8
(3,295 Views)
good idea, I will work on my VI to turn my VI more flexable to handle diferent input legths.

You wrote: Most likely the difference is that you are not returning the results in dB (boolean input)

I did not understand this, how do I should proceed to return my results in dB?

Another thing that I did forget to mention was that the values obtained from Power Spectral Density of Labview are 1000 fold lower AND a little bit different from that obtained from Specgram function of Matlab. This small difference is only observed when the values are analyzed in absolute values. When they are analyzed in normalized values (%), the results obtained from Labview and Matlab are the same. Do you guess something to explain this small difference in the absolut values?

Thank you very much for attention and help

Attached is a result file from Labview and from Matlab, obtained from the same data.

Thanks

Dan07


Message Edited by dan07 on 07-04-2008 02:23 AM
Download All
0 Kudos
Message 8 of 8
(3,271 Views)