11-19-2008 10:47 AM
hello,
i' m trying to get the power spectrum from any signal and to write the data into an txt file. That works fine, if I open the txt I get the following result
Time 17:08:42,581116
X_Dimension Frequency
X0 0.0000000000000000E+0
Delta_X 10.000000
***End_of_Header***
X_Value Rechteck mit gleichverteiltem Rauschen (Power Spectrum) Comment
0.000000 -47.133891
10.000000 -47.969874
20.000000 -44.571773
30.000000 -47.516583
40.000000 -45.565932
50.000000 -53.381087
I also want to write this information (frequency and value), into an array or matrix. My plan is to repeat this for e.g. 5 times so that in the result I have different values for 10Hz, 20Hz,30Hz and so on.
1. column Frequencies
2. column data first measurement
3. column data second measurement
4. ...
Ex:
0.000000 -47.133891 -34,736 -45,973 -45,973 -45,973
10.000000 -47.969874 -46.987 -45,973 ....
20.000000 -44.571773 -46,738 -45,973 ...
30.000000 -47.516583 -45,947 ...
40.000000 -45.565932 ... ... ...
my problem, if I write the dynamic data from the powerspectrum into an arry I only get the values back, not the frequencies.
where am I wrong?
11-25-2008 05:24 AM
Hi,
Thanks for posting. I've written a quick piece of example code that should hopefully give you all the tools you need to produce an array exactly how you'd like. Please find the code attached. Just to explain how it all fits together:
- First of all, you need to ensure that the array you are producing is outside the for-loop on the block diagram, otherwise the data will be overwritten for each iteration of the loop, and therefore the data displayed will only be from the final iteration. You should ensure that indexing is enabled on the tunnels of the data exitting the for-loop, so that this will automatically group the data into an array.
- Use the Loop Iteration number multiplied by a constant to create a value for the frequency at each iteration.
- Use the Insert into Array function to insert the array of frequency values in the 'zeroth' column, hence using the frequencies as the headers of each row.
I hope this helps! Please don't hesitate to ask if you like anything clarified or if you have any other questions, let me know how you get on. Look forward to hearing from you,
Best Regards
11-25-2008 05:34 AM
Hi,
Sorry, I forgot to ask what version of LabVIEW you're using. The code attached is written in 8.6, so if you find that you have any problems with opening it, let me know which version you have and I can save the file to an older version for you.
Best Regards