2D Array Interpolation
Example 1:
Matlab
% MATLAB code for linspace() to generate % row vectors of 4 points % Initializing a 2d array of dimensions 3*3 A=[1 2 3 4 5 6 7 8 9]; % Calling the linspace() function to % generate the row vectors of 4 points % in between and including 1 to 2 x = linspace(1, 2, 4); % Calling the interp2() function for % interpolation of above specified 2d array result = interp2(A, x(:), x) |
Output:
Example 2:
Matlab
% MATLAB code for linspace() and interp2() % Initializing a 2d array of dimensions 4*4 A=[0.69 1.76 0.089 2.0012; 5.89 1.25 0.47 0.55; 1.06 1.25 1.134 4.163; 2 1.7 0 2.4]; % Calling the linspace() function to % generate the row vectors of 7 points % in between and including 1 to 3 x = linspace(1, 3, 7); % Calling the interp2() function for % interpolation of above specified 2d array result = interp2(A, x(:), x) |
Output:
2D Array Interpolation in MATLAB
In this article, we are going to discuss “2D Array Interpolation” in MATLAB with the help of two linspace() and interp2() functions.