LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you build a 3d array and then average back to a 2d array?

I have run into a snag with my code and don't know where to go .. 

 

I am taking measurements that are being saved once to a 2d array once every 5 minutes. The data collection is going to be over the course of 72 hrs (so you can imagine the number of files). I want to save an averaged data file once an hour, which will be 12 - 2d arrays, using the same 2d array data that is saved individually each time. I know that you can create a 3d array and then average it on the 12th iteration, saving that file. I'm not entirely sure I am on the right path in trying to accomplish what I want ... but I hope I am.

 

I have unsuccessfully looked for existing forum posts regarding this, so if there is one, I would certainly appreciate a point in the right direction. 

 

Thanks for the help!

0 Kudos
Message 1 of 6
(2,471 Views)

Why don't you simply keep summing the 2D arrays in a shift register, then divide it by the number of additions. No file IO needed.

 

(btw, the FOR loop in your "average" state will always produce an empty array, because the shift register is not properly initialize, Lots of your code looks really fragile)

0 Kudos
Message 2 of 6
(2,465 Views)

Thanks for the suggestion, and taking the time to look at my issue. You said that the code looks fragile, what do you mean by that? 

 

 

0 Kudos
Message 3 of 6
(2,415 Views)

Do a Google search on "fragile code".  It's an easy trap for a novice programmer to fall into, and one an experienced programmer must do their best to avoid when pressured for a "quick fix" solution.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 6
(2,409 Views)

thanks, but now I am on to a competely different problem ... since the "average" state wasn't finished, the test was started and is saving a new file every 5 minutes for the next 72 hrs. (thats 864 files, save ya from doing the math)

 

I would like to still average these files, but don't know where to start. The files names are running in sequencial order and was thinking that I could open the names into an array and then loop the data with a shift register, dividing by the number of loops? does that make sense ... or am i coming at this from the wrong angle?

 

 

0 Kudos
Message 5 of 6
(2,405 Views)

Jared.Sweeney wrote:

I would like to still average these files, but don't know where to start. The files names are running in sequencial order and was thinking that I could open the names into an array and then loop the data with a shift register, dividing by the number of loops? does that make sense ... or am i coming at this from the wrong angle?


I would find the average of each of the files and then take the average of the average of the files.  Just use a FOR loop to go through all of the files.  Inside of the FOR loop, read all of the file and use the Mean.vi.  Autoindex the average out of the FOR loop.  Then you use the Mean.vi on the resulting array.  That will help keep the array size down.


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
0 Kudos
Message 6 of 6
(2,402 Views)