I have 2 datasets in Matlab that I need to build against each other - one on xaxis and one on yaxis. The data for each set were collected using a different method, so the sampling rate is significantly different, and until I get the same number of data points in both sets, I canโt build one by one.
Its quite simple to downsample data in matlab using the downsample matlab function.
A = [-3 -1.5 0 1.5 3 4.5 6 7.5 9...] (goes on until 21) B = [-3.9 -3.8 -3.7 -3.6 -3.5 -3.5 -3.3 -3.2 -3.1 -3.0 -2.9 -2.8...] (goes on until 22)
Sample rate A is 1.5 s and sample rate B is 0.1 s. I managed to successfully use downsample as downsample(B,15,10) to make it run at the same time as "-3s" (which means something in my data, so I need to get it to start at that point) and be in the sampling rate samples 1.5 s.
Now, however, I was wondering if there was a method that allowed me to take an average of 15 points instead of selecting one item every 15 points? downsample , the way I used it selects every 15th item. However, I would like him to average 15 points for me. Is there any way to do this?
I wrote a for loop for a simple / smaller vector to see if I can do this. For A = [1 2 3 4] I would like to condense the data so that A has only 2 records, so that they average A (1) and A (2), and then A (3) and A (4).
A = [1 2 3 4] for i = 1:3 P(i) = mean(A(i:i+1)) end
This, however, does not work as I want, because I do not want it to average A (2) and A (3). I want him to take the first 2 records, average them, then the next 2 records, and then average them. soon.
Does anyone help?
thanks