# Hello everyone, I would like to ask a question how to parameterize data points?

조회 수: 1(최근 30일)
Wesley 2021년 1월 18일
댓글: Rena Berman 2021년 5월 6일
The method of parameterization of data points is as follows:
##### 댓글 수: 3표시숨기기 이전 댓글 수: 2
Rena Berman 2021년 5월 6일

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

### 답변(1개)

Image Analyst 2021년 1월 18일
Wow, what a load of mathematical gobbledygook. Could they make it any more obtuse? Anyway, here is a start:
x = s.data1(:, 1);
y = s.data1(:, 2);
N = length(y);
plot(x, y, 'b.', 'LineWidth', 2);
grid on;
xlabel('x', 'FontSize', 20);
ylabel('y', 'FontSize', 20);
t = zeros(1, N);
denominator = abs(diff(x) .^ 2 + diff(y) .^ 2)
for k = 2 : N - 1
numerator =
t(k) = t(k - 1) + numerator / denominator;
end
t(end) = 1;
##### 댓글 수: 3표시숨기기 이전 댓글 수: 2
John D'Errico 2021년 1월 18일
The idea is to compute what I like to call a connect-the-dots arc length. I've also called it a cumulative chordal relative distance. That is, you connect each point with a straight line, thus a chord. The parameter t is the cumulative accumulation of those distances between pairs of points.
The parameter t is a monotonically increasing parameter as you move from one point to the next in the sequence. And this makes it a nice scheme to do interpolation, because it can be used for any set of points, regardless of how they traverse your domain. For example, you can use it to interpolate points around the perimeter of a circle. And you can also use it to interpolate a completely general curvilinear path through any space, in any number of dimensions.
In MATLAB, this scheme is used internally by cscvn. You can see the reference to Eugene Lee's centripetal scheme in the help thereof.
help cscvn
CSCVN `Natural' or periodic interpolating cubic spline curve. CS = CSCVN(POINTS) returns a parametric `natural' cubic spline that interpolates to the given points POINTS(:,i) at parameter values t(i) , i=1,2,..., with t(i) chosen by Eugene Lee's centripetal scheme, i.e., as accumulated square root of chord-length. When first and last point coincide and there are no double points, then a parametric *periodic* cubic spline is constructed instead. However, double points result in corners. For example, fnplt(cscvn( [1 0 -1 0 1;0 1 0 -1 0] )) shows a (circular) curve through the four vertices of the standard diamond (because of the periodic boundary conditions enforced), while fnplt(cscvn( [1 0 -1 -1 0 1;0 1 0 0 -1 0] )) shows a corner at the double point as well as at the curve endpoint. See also CSAPI, CSAPE, GETCURVE, SPCRVDEM, SPLINE. Documentation for cscvn doc cscvn
I use the same scheme in my tools interparc, arclength, and distance2curve.
Since you have shown how to compute it already, I could add that one can compute the parametric vector t in a vectorized form, using diff and cumsum, but the looped form is a simple way to do it. (I know of course that Image Analyst knows how to do that.) But one might do:
t = cumsum(sqrt(diff(x(:)).^2 + diff(y(:).^2));
t = [0;t/t(end)];
Now a typical interpolation would involve forming spline models x(t), y(t). Sometimes pchip models may be appropriate instead. For example, a similar question was asked recently, where the OP desired to not have the curve falling outside of the box of the points. pchip models for x(t), y(t) would be a good way to achieve that result.

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

### Community Treasure Hunt

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

Start Hunting!

Translated by