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?

 採用された回答

Star Strider
Star Strider 2015 年 2 月 20 日
編集済み: Star Strider 2015 年 2 月 20 日

0 投票

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 件のコメント

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

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

質問済み:

2015 年 2 月 20 日

コメント済み:

2015 年 2 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by