cscvn of a function, coefficients and breaks
조회 수: 2 (최근 30일)
이전 댓글 표시
Hey all together,
I have another question concerning the cscvn function. When I create a spline for a function with cscvn
yy = cscvn(xges)
and take a look at yy.coefs and yy.breaks
form: 'pp'
breaks: [1x25 double]
coefs: [48x4 double]
pieces: 24
order: 4
dim: 2
then I have nearly twice as much coefs as breaks. How is this possible and what does that mean? How can I create the piecewise polynomial functions out of my coefs? At the end I want to calculate the curvature of the function, but first I have to understand what this coefs mean, and how I can create the piecewise polynoms.
Thank you in advance,
David
댓글 수: 2
Lucie
2023년 11월 24일
Hello, I am facing the same issue. Did you receive an answer regarding the meaning of the coefficients?
Mathieu NOE
2023년 11월 24일
everything is in the doc
답변 (1개)
Bruno Luong
2023년 11월 24일
편집: Bruno Luong
2023년 11월 24일
This is how to use pp
m = 2;
n = 5; % 25 in the original question
points = rand(m,n);
pp = cscvn(points)
m = pp.dim;
p = pp.pieces;
% https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/INT-APP/PARA-centripetal.html
%D = diff(points,1,2);
%d = sqrt(sqrt(sum(D.^2,1)));
%t = cumsum([0 d]); % Eugene Lee's, equal to pp.breaks, see https://www.mathworks.com/help/curvefit/cscvn.html
t = pp.breaks;
ni = 200;
ti = linspace(t(1),t(end), ni);
loc = discretize(ti, t);
x = zeros(length(ti), m);
coefs = reshape(pp.coefs, m, p, []);
for k=1:p
ink = loc == k;
tik = ti(ink);
dti = tik - t(k);
for d=1:m
P = coefs(d, k, :);
x(ink,d) = polyval(P(:), dti);
end
end
close all
hold on
if m == 2
plot(points(1,:),points(2,:),'or'),
plot(x(:,1), x(:,2),'b.')
elseif m == 3
plot3(points(1,:),points(2,:),points(3,:),'or'),
plot3(x(:,1), x(:,2), x(:,3), 'b.')
else
warning('plotting not supported')
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spline Construction에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!