LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rolling average of 1D arrays

Solved!
Go to solution

As I said, you don't need any inner loop. the shift register needs to reside on the outer loop. Currently, you are reinitializing the shift register with an empty array every time the inner loop is called.

Message 21 of 25
(2,188 Views)

HI Christian, 

 

I am sorry to keep troubling you with this, but I am still having difficulty with this VI.  I went through and only connected the shift register to the outer while loop and removed the inner FOR loop with the mean sub-vi.  I tried a few variants of these steps but couldn't figure out where to wire certain things.  

 

1.  When I wired the shift register to only the WHILE loop, I could not figure ouut where to wire the top terminal of the "Replace Array Subset" .  I would have thought that it should have been the 0 element array and the new element should be my input waveform.  

 

2. I removed the FOR loop with the Mean in it, and tried to wire everything up both with and without the Mean sub-VI.  Neither worked.  When I did not use the Mean sub-VI, in the WHILE loop I tried to use an Index Array (and a Reshape Array as well) to convert the 2D array to a 1D array so I coulf plot it.  No dice.  When I tried to use the mean sub-VI, I could not wire it without an auto-indexing FOR loop, as the output of the Mean sub-VI is simply a number.  

 

An example code of what you were trying to describe would be must helpful.  To that end, I have included a broken version of the code I was trying to modiy with your suggestions.  I will be venting this insturment to make needed hardware repairs (oh joy!) but will work on this during my lunch break.  Thanks again for the help.  

 

 

 

Joe

0 Kudos
Message 22 of 25
(2,165 Views)
Solution
Accepted by topic author jdepalma

Just did some tests on the VI and found I had a few indexes flipped.  Here is an example of the VI in use.  I recommend just using the VI as is and adding it to your project as a subVI.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 23 of 25
(2,143 Views)

Hi Tim and Christian, 

 

Thank you both very much for your help.  With a bit of extra work (and coffee!) I was able to get everything to work.  I marked it as a solution and gave you both kudos.  Once again, many thanks!

 

 

 

 

Joe

0 Kudos
Message 24 of 25
(2,119 Views)

Attached is a simple demo using lossy queues to keep an array for doing a rolling average.

 

Open "Using Rolling Average.vi" and run it.

CLA
Message 25 of 25
(1,917 Views)