Hello everyone, I would like to ask a question how to parameterize data points?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
The method of parameterization of data points is as follows:
3 Kommentare
Antworten (1)
Image Analyst
am 18 Jan. 2021
Wow, what a load of mathematical gobbledygook. Could they make it any more obtuse? Anyway, here is a start:
s = load('data1.mat')
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 Kommentare
Image Analyst
am 18 Jan. 2021
Sorry, no. I think all you have to do is to fill out numerator. I left that for you because it sounds like a homework problem. And I have little idea what this thing is about. You probably know far, far more about this than me and would be in a better position to solve it.
John D'Errico
am 18 Jan. 2021
Bearbeitet: John D'Errico
am 18 Jan. 2021
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
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.
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!