Free-knot spline approximation (BSFK) problem
Mostrar comentarios más antiguos
@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 comentarios
Bruno Luong
el 22 de Sept. de 2022
I'm not I fully understand: why can't you fit the whole sets of data by concatenate them together? It wil provide the single pp and not several that you won't bother to merge
Bruno Luong
el 22 de Sept. de 2022
I see.
Can you share few consecutive pp structs (ideally 3-5) where you want to merge?
Bruno Luong
el 23 de Sept. de 2022
This warning is not dangereous in my experience.
Michal
el 23 de Sept. de 2022
Bruno Luong
el 23 de Sept. de 2022
Editada: Bruno Luong
el 23 de Sept. de 2022
What I can offer is reduced the data using median filter

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; % select which column
xj = cat(1, x{:,j});
yj = cat(1, y{:,j});
% Assuming the number of data is divisible by 100
reshape_xj = reshape(xj, 100, []);
reshape_yj = reshape(yj, 100, []);
reduced_xj = median(reshape_xj,1);
reduced_yj = median(reshape_yj,1);
pp = BSFK(reduced_xj,reduced_yj, 4);
% Graphic check
xi = linspace(min(xj),max(xj),1000);
yi = ppval(pp, xi);
plot(xj, yj,'c.');
hold on
plot(xi, yi, 'r', 'Linewidth', 2)
Bruno Luong
el 23 de Sept. de 2022
Result with
pp=BSFK(reduced_xj,reduced_yj,2,100);

Bruno Luong
el 23 de Sept. de 2022
BSFK is not supposed to do that. Its a fitting function and it produces a single pp.
You could always connect 2 piecewise functions in C1 manner by a 3rd order polynomial if there is a gap between them, since there are 4 conditions and 4 unknown.
It is likely not produce a nice transition since one pp ignores completely the data next to it.
Bruno Luong
el 23 de Sept. de 2022
Editada: Bruno Luong
el 23 de Sept. de 2022
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
el 23 de Sept. de 2022
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Polynomials en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
