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

3 ビュー (過去 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 Center および File ExchangeBar Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by