How to group and code 2 different parts of a graph.

조회 수: 1 (최근 30일)
Sarah Levovitz
Sarah Levovitz 2018년 7월 24일
답변: jonas 2018년 7월 24일
Hey,
I have a graph that repeats the same pattern over and over. In each 'period', there are 2 main parts to the graph, and I would like to compile a code that would allow me to separate these two parts so that I can then just call the name and work with that part of the graph. It's easier to explain using a picture, so here it is:
This repeats itself a bunch of times- here you can only see it repeat twice, but basically each 'period' has a phase 1 (black part) and a phase 2 (red part) and I'm just trying to separate the two so that I can then just call out 'phase 1' or 'phase 2' and it will refer to that part. One of the things I would like to find is the time (x axis) duration of each phase.
The actual graph looks like the second attached file (single red line on MATLAB), so you can see that for example using the gradient- positive or negative for the 2 phases, it might not work as phase 2 can sometimes have a small positive gradient.
Thank you very much!
  댓글 수: 2
madhan ravi
madhan ravi 2018년 7월 24일
Without any datas it is hard to interpret.
Sarah Levovitz
Sarah Levovitz 2018년 7월 24일
Here is the x and y data in excel

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

답변 (1개)

jonas
jonas 2018년 7월 24일
I happen to have your data from a previous question, so here is my suggestion:
I know that you already have the start value of the first change in slope, so you should remove the part of the signal prior to this point. Then you can use findpeaks to locate the peaks and throughs.
[~,p]=findpeaks(y,'MinPeakProminence',30);
[~,t]=findpeaks(y*-1,'MinPeakProminence',30);
figure;hold on
plot(x,y,'-',...
x(p),y(p),'o',...
x(t),y(t),'x');
Then you can just take the segments between each peak and through and structure this data however you wish.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by