Hello I am new to programming in Matlab and am attempting to find the number of data points within a set of data that are x standard deviations away from the mean. The dataset is 5,000 random numbers using randn. I would like to do this with a loop, and I think the steps are should take are as follows:
I am not really sure where to begin and if someone could point me in the right direction it would be greatly appreciated. Thanks.
N = 5000; % Number of data points
x = randn(N,1); % Random vector
mu = mean(x); % Mean of vector
sig = std(x); % Stan. dev. of vector
% This is a logical array that signifies where the
% condition is true.
inds = (x >= (mu - sig)) & (x <= (mu + sig));
Can you take it from here?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.