How do I get rid of certain values with the same X-axis value in a certain range?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Michael Arvin
am 23 Feb. 2022
Bearbeitet: David Goodmanson
am 23 Feb. 2022
Hello. I am trying to ignore/delete certain points in my data/plot. The x-axis is the time and the y-axis is the value. The time and value are both in 2 different matrices. The size of each is 8192.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/904165/image.png)
If I zoom in, it looks like this.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/904170/image.png)
I am trying to get rid of the value at a certain time that are more than the median within a certain range (for example +/-10).
Any ideas on how to do it?
Thank you very much!
0 Kommentare
Akzeptierte Antwort
David Goodmanson
am 23 Feb. 2022
Bearbeitet: David Goodmanson
am 23 Feb. 2022
Hi Michael,
here is one way, assuming that x (many values of which are repeated) and y are two columns.
tol = 10;
a = polyfit(x,y,1);
y1 = polyval(a,x);
ind = abs(y1-y) > tol;
x(ind) = [];
y(ind) = [];
The data appears to be very linear, so the code fits a straight line and kills off the points that are too far away from the line. This is not quite the same as a) finding the mean value of y for each group with the same x and b) killing off the points that deviate too much from each mean, but the results must be really similar.
0 Kommentare
Weitere Antworten (1)
KSSV
am 23 Feb. 2022
Put a logical conditioning, get indices and remove those points. Simple.
Example:
y = rand(1,10) ; % random data for demo
idx = y > 0.5 ; % get indices of values greater than 0.5
y(idx)= []; % remove them from y
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical 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!