Trying to extract outliers from array

1 view (last 30 days)
%Point Barrow, Alaska
PB=readtable('daily_flask_co2_ptb.csv');
%create time and CO2 variable
PBdailyt=PB(:,4);
PBdailyCO2=PB(:,7);
PB.t=table2array(PBdailyt);
PB.CO2=table2array(PBdailyCO2);
%extract outliers by finding and replacing with NaN
PB.CO2x=find(PB.CO2 >=450 | PB.CO2 <=300);
for i=1:length(PB.CO2);
PB.CO2x(PB.CO2(i))=NaN;
end
"To assign to or create a variable in a table, the number of rows must match the height of the table."
I used the table2array but the above message is still popping up when I try to find the outliers of the data. I also noticed that all expect the PB.CO2 & PB.CO2x variables are showing up in my workspace. If their is another way to find and extract the outliers that would be helpful.

Accepted Answer

KSSV
KSSV on 7 Dec 2021
Edited: KSSV on 7 Dec 2021
%Point Barrow, Alaska
PB=readtable('daily_flask_co2_ptb.csv');
%extract outliers by finding and replacing with NaN
idx = PB.CO2 >=450 | PB.CO2 <=300 ; % <-- you need to think on this condition
PB.Co2(idx) = NaN ;

More Answers (0)

Categories

Find more on Tables in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!