How to select data outside a defined range
Ältere Kommentare anzeigen
Hello All,
For a given data file, I'm interested to find the range of values that lie outside a range of values
Eg: For a range of values between -100 and +100, I only want the values that are greater than 20 and less than -20 (That means all the data values in between (i.e. between -20 and +20 are to be removed).
A = [-21 -15 -25 -10 0.4 10.6 17 24 44]
After condition check,
AOut = [-21 -25 24 44]
How can we carry out the same operation?
For this, I have implemented the below logic. It seems to work but I feel that it can be better optimised to be more efficient.
Cheers!
%TIn = Data file
[ii,jj] = find(~TIn);
Thr = zeros(size(TIn));
%Extract values that are below -15 and above +15
for k1=1:numel(TIn)
if (TIn(k1) < -15.0000)
Thr(k1) = TIn(k1);
elseif (TIn(k1) > 15.0000)
Thr(k1) = TVOut(k1);
end
end
%Remove zeroes
ThrO = nonzeros(Thr);
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Descriptive Statistics and Visualization finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!