How to detect the fluctuating point (cut-off point) of a signal?

4 次查看(过去 30 天)
Dear all,
I have a simple signal that I show below with blue color:
I want to find the point Xc. Any idea how find this point? Is it the same point which I will get from the first derivative of the signal?
Thank you very much.
Meshoo

采纳的回答

dpb
dpb 2014-12-9
The first derivative of your trace is a smooth positive curve that will have 2nd derivative that will approach zero at both ends. But the intersection point isn't at an inflection point, no...
Above shows how to fit the piecewise linear segments; you'll probably want to limit the fitting points to the end areas to get the better approximation to long-term slopes as you've drawn above; otherwise the slopes will tend to "sag" to the middle point by the OLS solution over the full data set.
  6 个评论

请先登录,再进行评论。

更多回答(2 个)

Image Analyst
Image Analyst 2014-12-21
Try this code. It will produce the image that follows it.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 25;
% Make up some demo equation.
x = 1 : 500;
y = sqrt(x);
% Plot it.
plot(x, y, 'b-', 'LineWidth', 2);
grid on;
title('Y = Sqrt(X)', 'FontSize', fontSize);
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Extract left and right segments of the curve.
numPoints = 15; % Whatever.
x1 = x(1:numPoints);
y1 = y(1:numPoints);
x2 = x(end-numPoints : end);
y2 = y(end-numPoints : end);
% Draw a green line going down from there.
line([x1(end), x1(end)], [0, y1(end)], 'Color', [0, .5, 0], 'LineWidth', 2);
line([x2(1), x2(1)], [0, y2(1)], 'Color', [0, .5, 0], 'LineWidth', 2);
% Find the equations of the line for each segment.
leftCoefficients = polyfit(x1,y1,1)
rightCoefficients = polyfit(x2,y2,1)
% Plot the lines in red.
yl = ylim(); % Save original y axis range.
hold on;
yLeft = polyval(leftCoefficients, x);
plot(x, yLeft, 'r-', 'LineWidth', 2);
yRight = polyval(rightCoefficients, x);
plot(x, yRight, 'r-', 'LineWidth', 2);
ylim(yl);
% Then set the two equations to each other and solve for xc:
xc = (rightCoefficients (2) - leftCoefficients (2)) / (leftCoefficients(1) - rightCoefficients(1))
yc = leftCoefficients(1) * xc + leftCoefficients(2);
% Draw a green line going down from there.
line([xc, xc], [0, yc], 'Color', [0, .5, 0], 'LineWidth', 3);
plot(xc, yc, 'o', 'MarkerSize', 25, 'Color', [0, .5, 0], 'LineWidth', 3);
% Put up text
message = sprintf('(xc, yc) = (%.1f, %.1f)', xc, yc);
text(1.1*xc, 0.5*yc, message, 'Color', [0, .5, 0], 'FontSize', fontSize);
  2 个评论
Meshooo
Meshooo 2014-12-22
Seems to be what I want and will test it soon. Thank you very very much..
dpb
dpb 2014-12-22
编辑:dpb 2014-12-22
I used the piecewise regression on your example dataset, IA, with initial guesses for the two slopes as
>> m1=Y(npts)/X(npts);
>> m2=(Y(end)-Y(end-npts+1))/(X(end)-X(end-npts+1));
>> b1=0;
>> c=X(end)/10;
>> coeff=nlinfit(X,Y,@piecewise,[b1 m1 c m2])
coeff =
1.1459 0.1940 58.0548 0.0225
The yc value is then
>> xc=coeff(3); yc=xc*coeff(2)+coeff(1)
yc =
12.4087
>>

请先登录,再进行评论。


Image Analyst
Image Analyst 2014-12-20
Take the first and last 10% or so of the points and fit a line.
numPoints = 10; % Whatever.
x1 = x(1:numPoints);
y1 = y(1:numPoints);
x2 = x(end-numPoints : end);
y2 = y(end-numPoints : end);
leftCoefficients = polyfit(x1,y1,1);
rightCoefficients = polyfit(x2,y2,1);
Then set the two equations to each other and solve for xc:
xc = (rightCoefficients (2) - leftCoefficients (2)) / (leftCoefficients(1) - rightCoefficients(1));
  3 个评论
Image Analyst
Image Analyst 2014-12-21
All right, I made it easy for you. See the code below in my other answer. Vote for my answer if it's useful to you.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by