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?

 Respuesta aceptada

Star Strider
Star Strider el 20 de Feb. de 2015
Editada: Star Strider el 20 de Feb. de 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 comentarios

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Centro de ayuda y File Exchange.

Preguntada:

el 20 de Feb. de 2015

Comentada:

el 20 de Feb. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by