# Finding a significant difference between two datasets

12 Ansichten (letzte 30 Tage)
Harry am 10 Mär. 2017
Kommentiert: Harry am 11 Mär. 2017
Hi,
I would like to find spikes in a dataset that are significantly different from a second dataset.
The picture attached shows two datasets and I would like to find the spike at 255 on the x-axis.
It would be helpful if I find these significant spikes automatically with a few commands.
I think it could be possible that I have to apply a tolerance or something that says only find data that has a greater difference than such and such (depending on the datasets that I compare).
So far I only could find the overall maximum y-value and its location but that's not what I want to find.
The output should be something like:
y = [max difference between two data sets]
x = [value at which significant difference occurs]
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

John Chilleri am 10 Mär. 2017
Bearbeitet: John Chilleri am 10 Mär. 2017
Hello,
Given data vectors a and b of equal length, you can use the following (assuming your x values are the default 1,2,...):
x = 1:length(a);
y = abs(b-a);
[y, ind] = sort(y,'descend');
x = x(ind);
Now the vector y contains the differences sorted from largest to smallest, and the x vector contains the corresponding x values.
Hope this helps!
##### 1 KommentarKeine anzeigenKeine ausblenden
Harry am 11 Mär. 2017
Thank you!

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

Steven Lord am 10 Mär. 2017
If you're using release R2017a take a look at the isoutlier function.
##### 1 KommentarKeine anzeigenKeine ausblenden
Harry am 11 Mär. 2017
Thank you!

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Multirate Signal Processing finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by