uniform knot vector for splines

71 vues (au cours des 30 derniers jours)
SA-W
SA-W le 12 Avr 2024 à 13:33
Modifié(e) : Bruno Luong le 13 Avr 2024 à 13:31
Suppose we have uniform interpolation points, e.g
x = [1 2 3 4 5 6]
x = 1x6
1 2 3 4 5 6
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
The functions for knot generation produce knots of the form
t = aptknt(x,5)
t = 1x11
1.0000 1.0000 1.0000 1.0000 1.0000 3.5000 6.0000 6.0000 6.0000 6.0000 6.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
where the first and last knot is repeated k times, but the breaks are no longer uniform. Similar for other knot functions like optknt.
I would like to carry over the property of equal distance between the interp. points to the knots. The knot vector
t = 1 1 1 2 3 4 5 6 6 6 6
satisfies this, as well as the Schoenberg-Whitney conditions. I arbitrarily repeated the first knot 3 times and the last knot four times.
Is such a knot vector plausible and why does MATLAB not offer functions for uniform knot sequences?

Réponse acceptée

Bruno Luong
Bruno Luong le 12 Avr 2024 à 15:45
Modifié(e) : Bruno Luong le 12 Avr 2024 à 15:55
Your knot sequence seems NOT to be suitable for interpolation. The interpolation matrix is singular.
x = linspace(1,6,6);
xi = linspace(min(x),max(x),61);
k = 5;
k1 = floor(k/2);
k2 = k-k1;
tSAW = [repelem(x(1),1,k1) x repelem(x(end),1,k2)]
tSAW = 1x11
1 1 1 2 3 4 5 6 6 6 6
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
t = aptknt(x,k);
for p=0:k-1
y = x.^p;
sSAW = spapi(tSAW,x,y); % Not workingn coefs are NaN
s = spapi(t,x,y);
subplot(3,2,p+1);
yiSAW = fnval(sSAW, xi);
yi = fnval(s, xi);
plot(x, y, 'ro', xi, yiSAW, 'b+', xi, yi, 'g-') % Blue curve not plotted since yiSAW are NaN
end
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
It seems Schoenberg-Whitney conditions are violated despite what you have claimed.
  7 commentaires
Bruno Luong
Bruno Luong le 13 Avr 2024 à 9:01
Modifié(e) : Bruno Luong le 13 Avr 2024 à 13:31
"That said, there is no way to have uniform knot breaks on the interpolation domain?"
What is the purpose of it? What if your x is non unform to start with, an assumption you never spell out.
You could chose
x = 1:6;
k = 5;
n = length(x);
dt =(max(x)-min(x))/(n-k+1);
teq = min(x) + dt*(-k+1:n)
teq = 1x11
-9.0000 -6.5000 -4.0000 -1.5000 1.0000 3.5000 6.0000 8.5000 11.0000 13.5000 16.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
OK = SWtest(x, teq)
OK = logical
1
figure
hold on
for i = 1:n
si = spmak(teq, accumarray(i, 1, [n 1])');
fnplt(si);
end
xlim([min(x) max(x)]);
or
dx = mean(diff(x));
dt = dx;
a = (n+k-1)/2;
teqx = mean(x) + dt*(-a:a)
teqx = 1x11
-1.5000 -0.5000 0.5000 1.5000 2.5000 3.5000 4.5000 5.5000 6.5000 7.5000 8.5000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
OK = SWtest(x, teqx)
OK = logical
1
figure
hold on
for i = 1:n
si = spmak(teqx, accumarray(i, 1, [n 1])');
fnplt(si);
end
xlim([min(x) max(x)]);
SA-W
SA-W le 13 Avr 2024 à 10:50
Modifié(e) : Bruno Luong le 13 Avr 2024 à 11:06
What is the purpose of it? What if your x is non unform to start with, an assumption you never spell out.
I know that my interpolant is barely sampled at some regions and I can circumvent this with the positioning of interpolation points x. For instance, when I do csape(x,y), the interpolation segments are determined by x, whereas for spapi and friends, the knot vector determiens the interpolation segments and I only have semi-control.
Anyway, if x is uniform, the knot vector aptknt(x,k) is uniform as well except at the boundary. So i can live with that. I was just wondering if there are alternatives and you provided some.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by