From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-29-2009 03:45 AM
Hi,
I am doing calculation of autocorrelation on a set of 4000 points time series dataset.
Labview has a build-in autocorrelation function which is for 2 points, see attached picture 1.
Now I wish to do 3 or 4 points autocorrelation on this dataset, see attached picture 2. I tried the silly method-nested for loop, see attached VI in LabView8.6.1, but it is very slow. Is there any good recipe for this calculation?
Thanks.
Wei
07-29-2009 04:28 AM
07-29-2009 04:46 AM - edited 07-29-2009 04:50 AM
Hi wei,
probably there's a better recipe then yours
I didn't change your algorithm, but cleaned up for LabView.
You should:
- remove constant values/operations out of loops/structures
- let LV do the tricky stuff (IndexArray gives back zero automatically, when index is out of range...)
- simplify (AddArray function instead of shiftregister+add function)
- do you really want to normalize the sum in each iteration??? Usually you normalize the scalar values before addition... (which again could be done by autoindexing/AddArray)
- avoid locals, even more in loops
- avoid sequence structures, especially when used just for hiding code...
- avoid (graph) indicators like "correlation R(t)" in loops when aiming for max speed!
You should check the 2D Correlation as suggested if it fits your needs.
Or do the calculations on "vectors", a sum(Xmn * Xjn * Xjm) can be done easily by multiplying and adding arrays in LabView...
07-29-2009 08:40 PM
Hi, THN,
Thanks for your reply.
I know the AutoCorrelation function in LabVIEW. But it is for 2 points calculation(both 1D and 2D
THN wrote:Hi Wei,
Is this the info that your looking for?
).
Best regards,
Wei
07-29-2009 08:50 PM
Hi GerdW,
Thank you very much. Your suggestion looks very helpful.
I am thinking about it.
The 2D AutoCorrelation works for 2-points, too.
By the way, why to avoid the sequence structures which is used very often?
Best regards,
Wei
GerdW wrote:Hi wei,
probably there's a better recipe then yours
I didn't change your algorithm, but cleaned up for LabView.
You should:
- remove constant values/operations out of loops/structures
- let LV do the tricky stuff (IndexArray gives back zero automatically, when index is out of range...)
- simplify (AddArray function instead of shiftregister+add function)
- do you really want to normalize the sum in each iteration??? Usually you normalize the scalar values before addition... (which again could be done by autoindexing/AddArray)
- avoid locals, even more in loops
- avoid sequence structures, especially when used just for hiding code...
- avoid (graph) indicators like "correlation R(t)" in loops when aiming for max speed!
You should check the 2D Correlation as suggested if it fits your needs.
Or do the calculations on "vectors", a sum(Xmn * Xjn * Xjm) can be done easily by multiplying and adding arrays in LabView...
Message Edited by GerdW on 07-29-2009 11:50 AM
07-30-2009 01:24 AM - edited 07-30-2009 01:31 AM
HI,
I tried the 2-points autocorrelation calculation on matrix. But it is said "Not enough memory to complete this Operation".
My computer: Intel Quad CPU Q9400, 3.37GB memory, windows XP pro sp3.
See attached program and data file (4000 data points). The matrix size would be 8000X4000.
Thanks,
Best,
Wei
07-30-2009 02:06 AM - edited 07-30-2009 02:09 AM
Hi Wei,
with "avoid locals" I didn't meant to use "value" property nodes - they are even worse than locals...
See the attachment, now without locals. It runs on my computer with only 1GB of RAM (vi needs ~256MB for data using your csv file)!
Edited:
Sequence structures are most of the time use- and senseless with LabView. They only hide code and are most often needed when programming in a non-LabView-style (like avoiding race conditions when using locals). Sequence disable parallel processing - and that's their only use in LabView...
07-30-2009 07:08 AM - edited 07-30-2009 07:12 AM
Hi, GerdW,
Thanks a lot. I really learned a lot from you.
Yes, it runs perfect after I restarted my computer.
I realized the calculation of 2 points autocorrelation through matrix multiplication which is fast as you see.
But, I am still confused how to convert the sum for 3 points autocorrelation to a matrix form.
Best regards,
Wei