How can I exclude specific data points from a data file?
13 views (last 30 days)
Show older comments
I have a file that contains multiple impedance measurmement data points at different frequencies. The data text file looks something like this and so on with hundreds of data points.
Frequency (Hz) Z (Ω)
100000 84052.0991922344
63096 118508.2434971
10000 255421.414881552
The data file is called rawData. I am trying to exclude impedance data points (Z) above 2500000 only when the frequency value is at 1000. So if the Z value is 3000000 when the frequency is 1000, I want to exclude that line of data from the file and have a new data file without the excluded data.
I attached what I have so far in my code, however, I am unsure on what function/command to use to exclude the data I would like to exclude.
%excluding impedance data of > 2.5 Mohms at 1 KHz frequency
l = length(rawData);
for i = 1:l
while rawData(i,1) == 1000
if rawData(i,2) >= 2500000
end
end
end
0 Comments
Answers (2)
Cris LaPierre
on 6 Dec 2020
Edited: Cris LaPierre
on 6 Dec 2020
I'm assuming you've already loaded the data file into the variable rawData in MATLAB. This is untested.
rawdata(rawData(:,1)==1000 & rawData(:,2)>2500000,:)=[]
0 Comments
dpb
on 6 Dec 2020
Just select the data want (or conversely, remove what don't want)...
Fout=1000;
ZLim=2.5E6;
isOut=(rawData(:,1)==Fout) & (rawData(:,2)>ZLim); % logical addressing vector of "Out"
data=rawData(~isOut,:); % save what is not "Out"
The above duplicates everything that isn't out; this is somewhat memory wasting as have duplicated same data a second time. May be what want to do if later will need the excluded data for some other purpose.
OTOH, if one doesn't have any other need for the excluded subset, then eliminate it and have only the wanted data...
rawData(isOut,:)=[]; % remove what is "Out"
In this case, "rawData" is now "cleanData" so maybe one just starts with the variable "data" instead. That, of course, is just user-friendly niceties; MATLAB doesn't care what you name it.
0 Comments
See Also
Categories
Find more on Cell Arrays 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!