Please help with the correct syntax for this interpolation (interp2)

2 views (last 30 days)
Hi,
I want to use a 2D-interpolation, but I do not understand the syntax of interp2. I simplified my acutal problem so it is easier to concentrate on what is going on.
Let say I have matrix A and I want to use interp2 to obtain matrix B. I want to have linear interpolation resulting in a matrix in which the steps between points in the last row of A become exactly 1. What should be the syntax so I can use a similar solution for my actual problem.
A = [2 4 6 8 10;
1 2 3 4 10];
% Here should be something like B = interp2(A,XXXXXXXX) to obtain the result below.
B = [2 4 6 8 8.3333 8.6667 9 9.3333 9.6667 10
1 2 3 4 5 6 7 8 9 10];

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 3 Mar 2021
That seems like a task for interp1:
B(2,:) = A(2,1):A(2,end);
B(1,:) = interp1(A(2,:),A(1,:),'linear');
HTH

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!