Finding change in a large dataset
조회 수: 5 (최근 30일)
이전 댓글 표시
Hello everyone,
I have a data file (1288753x1) as shown above (data attached)
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
2019년 10월 7일
편집: Adam Danz
2019년 10월 7일
"I have tried using ischange, but its not working."
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
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
댓글 수: 0
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
댓글 수: 0
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!