How to interpolate complex data along one dimension to a larger size?

2 views (last 30 days)
I have a 200by79 matrix (A) and want to interpolate to a 200by84 matrix (B). They are complex data. I followed the suggestion by Chad Greene:
samplepoints = linspace(1,10,79);
coordinatesofthequerypoints = linspace(1,10,84);
B = zeros(200,84);
for xx_ct = 1:200
B(xx_ct,:) = interp1(samplepoints,A(xx_ct,:),coordinatesofthequerypoints);
end
These codes just add NaN to B(:,79) to B(:, 84). Not my goal. What I want is to add 5 lines evenly distributed in the original 79 lines of A, the values of the new lines can be the average of the neighborhood lines, so that B is 84 lines. Is there a way to do this? Thank you.
  1 Comment
Adam
Adam on 29 Oct 2014
That all seems to work fine for me. Obviously I don't have your matrix A so I just used:
A = rand(200,79) + i * rand(200,79);
but the data was stretched out over the extra 5 points as expected.
interp2 might be faster than using interp1 with a for loop, though I don't know as I haven't tried it. You can just pass in the same grid for new and old in the 2nd dimension to do effectively no interpolation across rows, but whether interp2 is clever enough to see that and do no extra work I don't know.

Sign in to comment.

Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!