how to interpolate between two point of 1d time series data if the difference between any two consecutive point is greater than 25?

2 visualizaciones (últimos 30 días)
Hello every one please help!
I have atime seies data like this;
x = [5 10 36 20 17 5 51 60 40 13] and independent variables as follow
fs = 4;
t=0:1/fs:(L-1)/fs;
I want to use spline interpolation between two consecutive point of 'x' means (xi and xi+1) if the difference between two point is greater than 25. for example from the above time series x3-x2= 36-10= 26 therefore i want to interpolate between x2 and x3 with t interval of 0.05 and return all the new time series data.
anyone please help

Respuesta aceptada

DGM
DGM el 10 de Mayo de 2021
Maybe something like this:
x = [5 10 36 20 17 5 51 60 40 13];
L = numel(x);
fs = 4;
t=0:1/fs:(L-1)/fs;
idx = find(abs(diff(x))>25);
% i'm just going to build a whole new t vector
tf = [];
for d = 1:numel(idx)
a = idx(d);
if d==1 && a>1
tf = t(1):0.25:t(a); % pad head
end
% refine this segment
tseg = t(a):0.05:t(a+1);
tf = [tf(1:end-1) tseg];
if d==numel(idx) && a<numel(t)
tf = [tf(1:end-1) t(a):0.25:t(end)]; % pad tail
elseif d<numel(idx) && idx(d+1)>(a+1)
tf = [tf(1:end-1) t(a+1):0.25:t(idx(d+1))]; % pad between
end
end
% interpolate the whole thing
xf = interp1(t,x,tf,'spline')
plot(t,x); hold on
plot(tf,xf)

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by