finding slope of a signal

조회 수: 44 (최근 30일)
Sara
Sara 2018년 9월 6일
댓글: Dimitris Kalogiros 2018년 9월 6일
Hello. I have two signals (according to figure) and I want to find the slop of each signal.
Thanks for further help.
  댓글 수: 2
jonas
jonas 2018년 9월 6일
Well, as you can see the slope is varying. What exactly are you looking for? The trend? The change in every point?
Sara
Sara 2018년 9월 6일
sorry for the poor explanation. I want to get the trend.

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

채택된 답변

Dimitris Kalogiros
Dimitris Kalogiros 2018년 9월 6일
A script that calculates mean slope :
clc; clear; close all;
%%generate input signal
x=0:1:1500;
y=(-0.002*x+3)+abs(sin(2*pi*.002*x))+0.2*sin(2*pi*.01*x);
figure; plot(y, '-b'); zoom on; grid on;
xlabel('x'); title('input signal y'); hold on;
%%first order aproximation
p=polyfit(x,y,1);
polyValues=p(1)*x+p(2);
plot(polyValues,'--r');
legend('input signal', 'first order approximation');
%%slope detection
fprintf(' mean slope = %f \n', p(1));
Of course, I had to generate a signal similar to what you presented at your question.
If you run the script you will receive the following:
  댓글 수: 4
jonas
jonas 2018년 9월 6일
You can draw a line from the start point to the end point, but what's the point of that? It's certainly not indicative of future values.
Dimitris Kalogiros
Dimitris Kalogiros 2018년 9월 6일
@Sara , If the end point of the red line and the end point of the signal are the same , then you might have a significant error on what you have calculated as "mean slope". I believe, the method I used for the calculation of the "red line" is (probably) the best one.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by