Resample data points by taking average values
14 views (last 30 days)
Show older comments
Hi all,
I am looking for a way to resample data points. Assuming an array with around 50 data points, what I want to achieve is the following: - between each set of two data entries (1st and 2nd, 2nd and 3rd, 3rd and 4th, etc.) I want to take the average of the two points - This average I then want to insert into the array between each two of the respective points.
What will be the simplest way to do this?
0 Comments
Accepted Answer
Star Strider
on 20 Feb 2015
Edited: Star Strider
on 20 Feb 2015
I would use the interp1 function:
Array = randi(100, 50, 3);
IntVct = [1:0.5:50]';
Result = interp1([1:50]', Array, IntVct); % Output
The ‘Array’ variable here is assumed to be a (50x3) matrix. The code works without alteration if ‘Array’ is a vector. It does assume column-major orientation for a matrix. It doesn’t care about the vector being a row or column, but the output will be a column vector.
3 Comments
Image Analyst
on 20 Feb 2015
You can also use imresize() if you have the Image Processing Toolbox.
out = imresize(inputMatrix, [100, 100], 'Bilinear');
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!