03-27-2012 04:38 AM
Hello!
I have an 2D array that i process within a for-loop. The array consist of two columns, one for the date/time stamp and one for the corresponding data measurements.
What I need to do is to loop through the array at one point at a time, and calculate the mean from time t to time t+n (n is a set value, i.e 10 min). I think i pretty much have got the code right, but I need some help to finish it.
The pseudo-code should look something simple as this:
for time t to time t+n
calculate mean
By the way, the time between the measurements is not fixed, so I need to use the time and not the number of datapoints.
Greetings
Kristoffer
Solved! Go to Solution.
03-27-2012 04:56 AM
03-27-2012 05:20 AM
Thanks Gerd!
I was thinking that it might end up with something like that. May I ask if you have some example code or something? As I am having a bit of trouble with realizing the pseudo code..
Greetings
Kristoffer
03-27-2012 06:04 AM
Hi,
you should try something like this:
03-27-2012 06:30 AM
Thanks! Seemed to help me some way along the road!:)
Maybe I did not explaned the whole problem good enough.
I need to find the interval (of i.e. 10 min) with the lowest mean in my data. That means that i need to take time instance 0 (element 0 from the time/date column) and calculate the mean for the coming interval. Then I need to do the same for the next intervall and so on. To be able to find the lowest mean i guess all means should be saved to an array? It would also be easier to process the mean data later by doing that i guess?
Your code helped me a lot Rodèric, but I cant get it to work 100%. I seems like it doen't wont to update the mean continousley.
I have included my program as well as some test data, really really hoping that you or someone else can help me a bit further on this one!:)
Greetings
Kristoffer
03-27-2012 06:43 AM
Actually, think I solved it now! Thanks a lot for the help guys!:D
Greetings
Kristoffer
03-27-2012 07:07 AM
you're welcome
03-27-2012 08:01 AM
Seems like I maybe was a bit fast on this one, as I am still struggeling to calculate the moving average. As I am only processing one data point to the mean.vi pr iteration the mean.vi just returns the same number as it gets in. Any suggestions on this one?:)
Greetings
Kristoffer
03-27-2012 08:09 AM - edited 03-27-2012 08:10 AM
03-27-2012 08:19 AM
Hehe;) well, i kind of figured out that one, just could figure out how!:P
I have now attached a test dataset and the program;)