Finding change in a large dataset
    2 views (last 30 days)
  
       Show older comments
    
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 Comment
  Adam Danz
    
      
 on 7 Oct 2019
				
      Edited: Adam Danz
    
      
 on 7 Oct 2019
  
			"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).  
Answers (2)
  Daniel M
      
 on 7 Oct 2019
        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 Comments
  Star Strider
      
      
 on 7 Oct 2019
        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 Comments
See Also
Categories
				Find more on Spline Postprocessing in Help Center and File Exchange
			
	Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

