How to interpolate 2d->2d data

조회 수: 9 (최근 30일)
qnswi free
qnswi free 2018년 8월 4일
댓글: Adam Danz 2018년 8월 5일
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 ?

답변 (1개)

Adam Danz
Adam Danz 2018년 8월 4일
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
qnswi free
qnswi free 2018년 8월 4일
Hi, thanks for your answer. The two sets of data are [2, n] matrix coordinates.
What I am originally trying to do is to flatten a closed polygon on the x-axis. To do so, I have a set of coordinates (x,y) that I know the 'flattened' coordinates (x', y'). Typically the set of (x,y) coordinates correspond to the medial axis and the contour of the object (see the image attached).
Then, I want to get the 'flattened' coordinate of any point within the original polygon. I first try to interpolate separately the x'(x,y) and y'(x,y) functions (using scatteredInterpolant function in matlab), but the result is not accurate in some cases where the curvature of the object is important.
I think a direct 2d->2d interpolation might solve this problem, but I don't see any way of doing this in Matlab.
Adam Danz
Adam Danz 2018년 8월 5일
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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by