Sensing the data changes and plotting

I have a table "a" which has multiple rows and 2 columns; t for time and q for data. I attached here.
I want to plots the period only where the sudden change of value happens (from start to end of the changes) such as I showed in figure where the value jumped from nearly -4 to -43.65.
After that I'd like to generate a table of the data of the plot. There will be many periods where such kind of data changes occurs so I want to plot everytime with that data changes.
load = 'newdata3.csv';
data = readtable(load);
data = sortrows(data,'Var1','ascend');
timetable(data.Var1, data.Var2);
plot(data.Var1,data.Var2)
findchangepts(data.Var2,'MaxNumChanges',20)
Here, I tried and it is not showing at the correct changes points. There are 12 changes points and it is only showing 5 of them. I don't know how to fix this.

답변 (1개)

Image Analyst
Image Analyst 2022년 10월 27일

0 개 추천

Do you have the Image Processing Toolbox? If so, it's easy.
v = a.V;
mask = v > 200
props = regionprops(mask, 'PixelIdxList');
numRegions = numel(props);
coords = vertcat(props.PixelIdxList);
startingRows = coords(:, 2);
or something similar. It would have been easier if you had read the posting guidelines and remembered to attach your data.
To learn other fundamental concepts, invest 2 hours of your time here:
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

댓글 수: 12

uzzi
uzzi 2022년 10월 27일
Thank you for your guideline. I watched that free 2 hours training. That was helpful. I took your advice and improved my question with the attachment. But your code is not working for my file. Can you take a look into it again with my attached csv file?
Image Analyst
Image Analyst 2022년 10월 28일
Did you try findchangepts?
uzzi
uzzi 2022년 10월 28일
Yes, I tried. It doesn't show any changes
Your data looks weird:
a = readtable('newdata3.csv')
a = 126000×2 table
Var1 Var2 ___________ _______ 12:14:54 AM -3.3268 12:14:54 AM -4.1778 12:14:54 AM -4.6337 12:14:54 AM -4.729 12:14:54 AM -4.9851 12:14:54 AM -4.2736 12:14:54 AM -3.2882 12:14:54 AM -2.257 12:14:54 AM -1.5046 12:14:54 AM -1.6617 12:14:54 AM -1.4103 12:14:54 AM -2.4553 12:14:54 AM -3.3668 12:14:54 AM -4.193 12:14:54 AM -5.1044 12:14:54 AM -5.133
t = a.Var1;
v = a.Var2;
plot(t, v, 'b-');
grid on;
mask = v > 20;
props = regionprops(mask, 'PixelIdxList');
numRegions = numel(props)
numRegions = 310
startingRows = vertcat(props.PixelIdxList)
startingRows = 6462×1
54011 54013 54014 54015 54016 54017 54018 54019 54020 54021
uzzi
uzzi 2022년 10월 28일
I think that's lack of table sorting. After I read the table in MATLAB, I sort the rows ascending with time. a = sortrows(a,'Var1','ascend'); Maybe that's why.
Image Analyst
Image Analyst 2022년 10월 28일
OK, what's your threshold? It looks like you could use a global threshold everywhere, like 5 or something.
uzzi
uzzi 2022년 10월 29일
The threshold is 20 and -20.
uzzi
uzzi 2022년 10월 29일
Is it possible to use image processing commands for data processing?
Image Analyst
Image Analyst 2022년 10월 30일
Yes, of course. Images are data. And many of the image processing functions work just as well on 1-D signals as well as 2-D and 3-D images.
uzzi
uzzi 2022년 10월 31일
Are there anyway to generate graph automatically in the areas when big data changes happens?
Image Analyst
Image Analyst 2022년 11월 1일
Yes. But I don't know what you want.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
uzzi
uzzi 2022년 11월 1일
I think you didn't understand my question. That's the question I'm asking from the start. I can plot in conventional way. According to the plot, you can see that there are 6 places where big data changes happen.
What I want is I want the MATLAB to sense the data automatically and generate a graph where a big data changes is sensed.
In this case, I want the MATLAB to automatically generated 6 figures where big data changes occurs.
I hope this explanation is clear to you.

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

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

제품

질문:

2022년 10월 27일

댓글:

2022년 11월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by