Extrapolating intersection points (signal processing/curve fitting)

10 visualizaciones (últimos 30 días)
I have a data set which consists of a series of adjacent dips. Below I have plotted the data using the line style specifier '-o' which connects two adjacent points using a line. I want to determine the points where the red line (some arbitrary threshold) intersects the blue line. How can this be achived?
plot.png
In other words, I am looking for the simplest way to extrapolate my data at a certain threshold value. I believe a linear fit using polyfit can be used to find the straight line between two neighbours. But I am not sure how it can be applied to this problem.
Any suggestions would be greatly appreciated.
P. S. I am including my sample data which can be accessed through:
M = csvread('DS0006.csv');
time = M(:,1); waveform = M(:,2);
waveform = smooth(time,waveform,5,'moving'); plot(time,waveform, 'o-');

Respuesta aceptada

Star Strider
Star Strider el 6 de Mayo de 2019
Another approach:
M = xlsread('DS0006.csv');
time = M(:,1);
waveform = M(:,2);
threshold = 3.2;
zci = @(v) find(v(:).*circshift(v(:), [-1 0]) <= 0); % Returns Approximate Zero-Crossing Indices Of Argument Vector
thrx = zci(waveform-threshold); % Approximate Indices Of ‘threshold’ Equality
for k1 = 1:numel(thrx)
ixr = thrx(k1):thrx(k1)+1; % Index Range For Linear Interpolation
dm = [time(ixr) [1; 1]]; % Design Matrix
bv = dm \ waveform(ixr); % Parameter Vector
xi(k1) = (threshold-bv(2)) / bv(1); % Interpolate To Find ‘x’ At ‘threshold’
end
figure
plot(time, waveform, '.-')
hold on
plot(xlim, [1 1]*threshold, '-r')
plot(xi, threshold*ones(size(xi)), 'xg', 'MarkerSize',10)
hold off
xlim([0 1.5E-4])
Extrapolating intersection points (signal processing - curve fitting) - 2019 05 06.png
This produces interpolations of the x-values (the ‘xi’ vector) where your data crosses the ‘threshold’ value. It uses simple linear interpolation and is reasonably fast and efficient.

Más respuestas (1)

John D'Errico
John D'Errico el 6 de Mayo de 2019
Editada: John D'Errico el 6 de Mayo de 2019
Download Doug Schwarz's utility: intersections.
But this has nothing to do with extrapolation. It just requres you to find the intersections between two pairs of line connected curves.

Categorías

Más información sobre Get Started with Curve Fitting Toolbox 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