Free-knot spline approximation (BSFK) problem

조회 수: 12 (최근 30일)
Michal
Michal 2022년 9월 22일
편집: Bruno Luong 2023년 1월 12일
@BrunoLuong
My data acquisition system produce periodically 1-D measured noised data with the fixed time window length W. I want to produce smoothed data for each window W separately, with specific constraints on continuous (k=2) or smooth (k = 3 or 4) processed signal connections between consecutive time measurement windows. So, for each window W I get finally separate "pp" structure. How to set proper BSFK options setting to fulfil these constraints?
The second question is: Is there any method how to merge separate "pp" structures to one "pp" structure for several processing windows at one?
Add note: May by some processing windows overlap could be required. Do you have any experiance with using BSFK in streaming regime?
  댓글 수: 13
Bruno Luong
Bruno Luong 2022년 9월 23일
편집: Bruno Luong 2022년 9월 23일
You could try to recursively enforce the continuity for function/derivative when you call BSFK on the next interval using the pp of the previous interval, just tell BSFK to have function/derivative of the most left knot (current) = previous pp function/derivative at the right knot (previous).
Michal
Michal 2022년 9월 23일
Yes, something like this I would like to try, but I don't know how exactly implement this type of fix by "shape" and "pntcon" options. This is the main reason why I need your help.

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

채택된 답변

Bruno Luong
Bruno Luong 2022년 9월 23일
편집: Bruno Luong 2023년 1월 12일
Here is the recursive pointwise constraint. You'll see it does the job (zoom in) the transition is not nice
data=load('result_4_8.mat')
data=data.result;
[m,n] = size(data);
x = cellfun(@(data) data.x, data, 'unif', 0);
y = cellfun(@(data) data.y, data, 'unif', 0);
j = 1; % n
close all
figure
hold on
for i = 1:m
% Normalize data so that dy/dx is comparable to y
xij = x{i,j}/10000;
yij = y{i,j}/10000;
options = struct('lambda', 1e-8);
if i >= 2
xleft = pp.breaks(end);
yleft = ppval(pp,xleft);
ydleft = ppval(ppder(pp),xleft);
xij = [xleft; xij];
yij = [yleft; yij];
pntcon = struct('p', {0 1}, 'x', {xleft,xleft}, 'v', {yleft ydleft});
options.pntcon = pntcon;
end
pp =BSFK(xij, yij, 4, [], [], options);
xi = linspace(min(xij),max(xij),1000);
yi = ppval(pp, xi);
plot(xij, yij,'c.');
plot(xi, yi, 'r', 'Linewidth', 2);
drawnow
end
function ppd = ppder(pp)
ppd = pp;
coefs = ppd.coefs;
n = size(coefs,2);
ppd.coefs = coefs(:,1:n-1).*(n-1:-1:1);
ppd.order = ppd.order-1;
end
  댓글 수: 5
Bruno Luong
Bruno Luong 2022년 9월 29일
I haven't not studied the complexity of BSFK.
But it seems to me the linear dependency to number of knots is not quite true, I would say it is more like quadratic.
Michal
Michal 2022년 9월 29일
Of course, this is my mistake ... you are right! CPU time dependency to number of knots is ~ quadratic!!!

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by