-1

I have data arrays in matlab like this: 1 , 2 , 3 ; 2 , 4 , 6 ; ... is there a ready to use algorithm in Matlab which can interpolate data and give me something like this (for linear e.g) 1 , 2 , 3; 1.5 , 3 , 4.5; 2 , 4 , 6;

in this example my steps are going to 0.5 instead of 1. this is the easy case for linear interpolation. imagine i have 10000 rows and i want have cubic interpolation and increase the resolution between my data.... I know there is mathematics algorithms but first I want to make sure if there is any ready to use function for that.

  • 1
    Googling for “MATLAB interpolate” gives lots of solutions, with relevant MATLAB documentation at the top. Please put a bit of effort into searching before you ask. And when you ask, show your efforts and why those don’t solve your problem. See [ask]. – Cris Luengo Apr 21 '19 at 18:19

1 Answers1

1

I think you want Matlab's interp1 function.

% Data points to interpolate
v = [1 2 3
     2 4 6
     ];
% X (independent variable) points for the original data
x = [1:size(v,1)]';
% X points to do the interpolation at
xq = [1:0.5:size(v,1)]';
% Do the interpolation
v_interp = interp1(x, v, xq);

The fourth argument to interp1() is an option that specifies what interpolation method to use, and takes arguments like 'linear', 'cubic', 'spline', and so forth. See doc interpn for details.

Decrease the step size in xq = [1:0.5:size(v,1)]' to increase the resolution.

Andrew Janke
  • 23,508
  • 5
  • 56
  • 85