How to interpolate 2d->2d data
12 views (last 30 days)
Show older comments
I have two sets of data. The first set of data contains (x,y) coordinates of a certain number of points, and the second set of data corresponds to the (x',y') image coordinates of the (x,y) points. Is there a way to interpolate this transformation ?
0 Comments
Answers (1)
Adam Danz
on 4 Aug 2018
Your question isn't super clear but I think I understand what you want.
The first data set is (x,y) coordinates. I interpret this as a [n-by-2] matrix of [x,y] coordinates.
The 2nd data set is the same coordinates in (x',y') format which is a vector [1, n*2].
If that's correct, here's how to reshape each data set to the other format. No interpolation is needed.
% Fake data
x = [1:5]';
y = [11:15]';
set1 = [x,y];
set2 = [x',y'];
% set1 -> set2
set_2 = set1(:)'
% set2 -> set1
set_1 = reshape(set2', [], 2)
2 Comments
Adam Danz
on 5 Aug 2018
That's much clearer (and different) from your question. But there are still some points to clarify. From your attached image, you have the (x,y) coordinates of the black line on the left and you have the (x2,y2) coordinates of the black line on the right, but you'd like to perform the transformations of the left coordinates to the right. Is that correct?
Could you share a minimal working example of your code? Could you also show us what's wrong with the scatteredInterpolant output?
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!