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

3 次查看(过去 30 天)
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 个评论
Adam
Adam 2014-10-29
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by