MATLAB Answers

Interpolate 1 array to another

6 views (last 30 days)
Sarah Yun
Sarah Yun on 18 Jan 2020
Answered: Akira Agata on 19 Jan 2020
Hello,
I want to interpolate a 5x9000 numeric array onto a 2000x3000 numeric array.
Other words, I want both arrays the same size.
What code is easiest for this?

  0 Comments

Sign in to comment.

Answers (2)

Image Analyst
Image Analyst on 18 Jan 2020
If you have the Image Processsing Toolbox, use imresize():
array1NewSize = imresize(array1, size(array2));

  0 Comments

Sign in to comment.


Akira Agata
Akira Agata on 19 Jan 2020
If you don't have the Image Processing Toolbox, interp2 would be your friend, like:
% assuming array1 is a 5x9000 numeric array
[xGrid, yGrid] = meshgrid(linspace(0,1,9000),linspace(0,1,5));
[xGrid2, yGrid2] = meshgrid(linspace(0,1,3000),linspace(0,1,2000));
array1NewSize = interp2(xGrid,yGrid,array1,xGrid2,yGrid2);

  0 Comments

Sign in to comment.

Sign in to answer this question.


Translated by