Resample data points by taking average values

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?

 Réponse acceptée

Star Strider
Star Strider le 20 Fév 2015
Modifié(e) : Star Strider le 20 Fév 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 commentaires

Rafi
Rafi le 20 Fév 2015
Perfect. Thanks.
Star Strider
Star Strider le 20 Fév 2015
My pleasure!
You can also use imresize() if you have the Image Processing Toolbox.
out = imresize(inputMatrix, [100, 100], 'Bilinear');

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by