How do I find the std of a specific range of data?

I need to determine the standard deviation of the noise in a seismic signal Time domain. The data is in the form of time vs amplitude. I wish to find the standard deviation of the amplitude between time=0.1 and time=0.6. I need to know how to take the std of a range of the data set as opposed to the whole data set.

3 Comments

This is the code I am using:
if true
% code
load a.MAT % load data file
a=A16; % define data set
at=a(:,1); % assign time data to variable
a1=a(:,2); % assign amplitude data to variable
a1s=a1-mean(a1); % DC offset shift to zero
Q = a1s((at>=0.2 & at<=.6)); % select noise range
W = at((at>=0.2 & at<=.6)); % select time data for noise range
end
However the selection of the noise range executes vary slowly. Does anyone have a suggestion for stream lining the code so that MATLAB can execute the data selection more quickly.
How many rows does the data set contain?
size(a,1)
Also, are the time steps uniformly spaced, or variably spaced? If uniform, what is the time increment?
at(2) - at(1)
Total rows of entire data set = 189857
Time steps are uniformly spaced at 9.06 micro seconds

Sign in to comment.

 Accepted Answer

Please try:
tic;
data = load('a.mat'); % this form is faster than
% command syntax
t = data.A16(:,1); % eliminate unnecessary data copies
a = data.A16(:,2);
a = a - mean(a);
idx = (0.2 < t & t < 0.6); % this operation is time consuming
% compute once, use result twice
Q = a(idx);
W = t(idx);
elTime = toc; % elapsed time
HTH.

More Answers (0)

Categories

Find more on Seismology in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!