Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB excluding data outside 1 standard deviation

I'm inexperienced with MATLAB, so sorry for the newbie question:

I've got a large vector (905350 elements) storing a whole bunch of data in it. I have the standard deviation and mean, and now I want to cut out all the data points that are above/below one standard deviation from the mean. I just have no clue how. From what I gather I have to make a double loop of some sort?

It's like: mean-std < data i want < mean + std


1 Answers

If the data is in variable A, with the mean stored in meanA and the standard deviation stored in stdA, then the following will extract the data you want while maintaining the original order of the data values:

B = A((A > meanA-stdA) & (A < meanA+stdA));

Here are some helpful documentation links that touch on the concepts used above: logical operators, matrix indexing.

like image 137
gnovice Avatar answered Jun 10 '26 05:06

gnovice



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!