Finding change in a large dataset

조회 수: 5 (최근 30일)
Ajay Kumar
Ajay Kumar 2019년 10월 7일
답변: Star Strider 2019년 10월 7일
Hello everyone,
I have a data file (1288753x1) as shown above (data attached)
pic.jpg
I am trying to find the y value at the red circles.
I have tried using ischange, but its not working.
Any help would be appreciated. Many Thanks.
  댓글 수: 1
Adam Danz
Adam Danz 2019년 10월 7일
편집: Adam Danz 2019년 10월 7일
"I have tried using ischange, but its not working."
Nine times out of ten the phrase "its not working" means "I couldn't get it to work". :)
An example in the ischange() documentation is applied to similar step-like data so I'd imagine that it could work for your step function as well. We'd need to see what you tried along with the input data to suggest modifications to the inputs.
But perhaps a lower level solution would be better. If your data are a step function (as appears to be the case) you'd just need to differentiate the x values using diff() and look for differentiated values very close to 0 (if not exactly 0). Perhaps you may need a second requirement that the difference in y should also exceed some threshold at indices where x didn't change.
These lower level approaches are usually easy to implement, quicker than the data processing approaches, easier to understand and write about, and you know exactly what's going on (you could know the precise methods for the data processing approach, too, if you spend the time to investigate).

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

답변 (2개)

Daniel M
Daniel M 2019년 10월 7일
I agree with what Adam says in that there are certainly more efficient ways to solve this problem. That being said, I didn't have any issue using ischange to find the required values.
load('data')
ch = ischange(rel_P_set_200);
vals = maxk(rel_P_set_200(find(ch)),2);
vals =
0.6468
0.6467

Star Strider
Star Strider 2019년 10월 7일
The ischange function needs to be told what you want it to do.
D = load('Kdata.mat');
y = D.rel_P_set_200;
x = 1:numel(y);
[cp,p] = ischange(y, 'linear', 'MaxNumChanges',4);
cpi = find(cp);
cpis = cpi([1 4]);
figure
plot(y)
hold on
plot(x(cpis), y(cpis), 'p')
hold off
grid
#Finding change in a large dataset - 2019 10 07.png

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by