
How can I calculate the daily average values of data matrix

sfz_cn
Hello, there
How do I calculate the daily average values of the data matrix based on the corresponding time wave, which may lack some hours in one day or some days? If there are any easier method without using the loop after adding missing time points?
AFAIK there is no way to do what you want without writing a loop. I've approached this problem previously by generating a numerical classifier wave, which in your case would have each day as a distinct integer. This wave could then be used to extract the data from the matrix (in a loop, day by day) and generate the average and storing it in a separate wave.
April 1, 2019 at 09:16 am - Permalink
Thanks for the timely answer, sjr51! It's very kind of you to share your experience in the process of calculating data. I also have an idea to calculated the data, but I think the method you provided is better. So I wonder if it is convenient to share the Igor code to me? I would appreciate it very much!
April 1, 2019 at 10:16 pm - Permalink
Sure, here's some old code to do this for a 1D wave. It works in Igor 7 or 8. You'd need to change the code a bit for it to work with 2D waves (for example, Variable nPnts = dimsize(inW,0)).
I don't know how you want to average your data per day, e.g. one value per day (average of all columns and all rows) or average of each column per day. In the former case, you can generate a 1D wave from your matrix which contains the averages of each row and then use that with this code as it is.
Finally, to make your keywave (numerical classifier wave), you could calculate the number of days from the first day/time in your date wave, rounding down using floor(). Hopefully this makes sense!
April 2, 2019 at 07:01 am - Permalink
Thanks for sharing your code to me and sorry for the delayed reply! Actually, I have found the method to adjust the code based on the suggestion you posed to me! It's very helpful and thanks again!
April 5, 2019 at 01:57 am - Permalink
In reply to Thanks for sharing your code… by sfz_cn
To reward those who helped you, please share your solution.
April 5, 2019 at 04:10 pm - Permalink