01-28-2009 11:59 PM - edited 01-29-2009 12:01 AM
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
01-29-2009 04:22 AM
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
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
@+
Tinnitus01-29-2009 05:33 AM
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
01-29-2009 07:19 AM
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
01-29-2009 08:45 AM
hello,
tell if this is more or less what you are looking for
@+
Tinnitus
01-29-2009 10:43 AM - edited 01-29-2009 10:44 AM
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
01-29-2009 12:18 PM
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
01-29-2009 12:59 PM
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
01-29-2009 02:10 PM
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
01-29-2009 06:27 PM
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