How to select only that rows from which I have values in all columns?

7 views (last 30 days)
I have multiple cloumns of specific variables, and there hourly data for many years. I want to select only those data for which I have vlaues in last three columns.
My data is :
YEAR MONTH DAY HOUR PM2.5 PM10 BC σsp(525) ssa σap(520) α Ntotal Nuc (<25nm) Ait (25-90nm) Acc(>90nm)
2006 4 16 9 43 135 1.23 17.26 1.17 4639 28 1901 2710
2006 4 16 10 40 75 1.06 15.29 1.22 3782 31 1302 2449
2006 4 16 11 34 169 0.82 11.79 1.19 3372 74 1087 2211
2006 4 16 12 39 5 1.32 19.91 1.33 4083 127 1060 2896
2006 4 16 13 45 179 1.59 24.41 1.37 6054 1813 1240 3001
2006 4 16 14 41 60 1.50 22.01 1.26 6269 1840 1544 2885
2006 4 16 15 42 129 1.75 26.01 1.28 5868 1096 1475 3297
2006 4 16 16 44 116 1.52 22.10 1.22 4928 848 1308 2772
2006 4 16 17 40 144 1.53 23.93 1.39 5377 460 1558 3359
2006 4 16 18 47 118 1.68 25.50 1.32 4990 327 1686 2977
2006 4 16 19 39 113 1.67 25.28 1.34 5698 228 2196 3274
2006 4 16 20 44 121 1.76 26.36 1.32 5633 137 2039 3458
2006 4 16 21 47 96 1.96 29.74 1.36 6658 75 2282 4301
2006 4 16 22 49 97 1.70 27.93 1.57 7459 55 2558 4847
2006 4 16 23 49 96 1.79 28.84 1.51 6614 49 2187 4378
2006 4 17 0 40 57 1.55 112.2 0.82 23.62 1.35 4800 45 1402 3354
2006 4 17 1 36 61 1.48 106.8 0.83 22.03 1.28 4254 40 1161 3053
2006 4 17 2 36 75 1.18 96.9 0.85 17.65 1.28 3892 39 1054 2798
2006 4 17 3 31 58 1.35 94.0 0.82 20.62 1.34 3466 26 859 2582
2006 4 17 4 47 120 1.41 93.8 0.82 21.17 1.31 3377 21 807 2548
2006 4 17 5 37 42 1.58 95.9 0.80 23.44 1.27 3556 18 881 2657
2006 4 17 6 43 119 1.39 91.4 0.82 20.41 1.25 3492 27 928 2537
2006 4 17 7 34 1.30 89.1 0.82 18.87 1.23 3674 56 1113 2505
2006 4 17 8 36 1.09 94.8 0.85 16.94 1.39 4039 53 1219 2766
2006 4 17 9 36 35 1.05 77.7 0.82 16.34 1.40 3347 53 1074 2220
2006 4 17 10 37 66 0.93 67.9 0.83 14.08 1.33 2909 52 960 1897
2006 4 17 11 45 49 0.94 70.7 0.83 14.07 1.30 3130 36 1076 2018
2006 4 17 12 28 43 0.86 65.5 0.83 12.83 1.29 3040 43 1088 1909
2006 4 17 13 24 50 0.76 57.9 0.84 11.27 1.25 2779 42 1042 1695
2006 4 17 14 28 39 0.72 54.1 0.84 10.43 1.22 2707 53 1093 1561
2006 4 17 15 25 35 0.68 51.5 0.84 9.81 1.18 2606 84 1059 1463
2006 4 17 16 24 47 0.57 47.7 0.86 8.11 1.19 2443 62 1009 1372
2006 4 17 17 25 54 0.86 12.50 1.31 3321 97 1512 1712
2006 4 17 18 40 89 0.53 8.11 1.31
2006 4 17 19
2006 4 17 20
2006 4 17 21
2006 4 17 22
2006 4 17 23
2006 4 18 0
2006 4 18 1
2006 4 18 2
2006 4 18 3
2006 4 18 4
2006 4 18 5
2006 4 18 6
2006 4 18 7
2006 4 18 8
2006 4 18 9
2006 4 18 10
2006 4 18 11 38 0.43 6.15 1.22 2017 34 919 1064
2006 4 18 12
2006 4 18 13
2006 4 18 14
2006 4 18 15
2006 4 18 16
2006 4 18 17
2006 4 18 18 9 55 0.51 7.56 1.30 2720 64 1200 1456
2006 4 18 19 20 59 0.59 9.03 1.37 2945 59 1335 1552
2006 4 18 20 18 37 0.47 7.00 1.29 2083 36 899 1148
2006 4 18 21 11 19 0.58 7.97 1.10 2376 78 1084 1214
2006 4 18 22 20 26 0.69 9.69 1.19 3119 87 1463 1569
2006 4 18 23
2006 4 19 0
2006 4 19 1
2006 4 19 2
2006 4 19 3
2006 4 19 4
2006 4 19 5
2006 4 19 6
2006 4 19 7
2006 4 19 8
2006 4 19 9
2006 4 19 10 27 0.39 38.3 0.88 5.38 1.12 2668 40 1477 1151
2006 4 19 11 55 0.48 44.2 0.87 6.96 1.19 2861 43 1563 1255
2006 4 19 12 37 0.52 42.3 0.85 7.43 1.19 3354 117 1911 1326
2006 4 19 13 24 0.53 44.0 0.86 7.43 1.16 3702 255 2022 1424
2006 4 19 14 29 0.61 47.4 0.85 8.58 1.15 4506 618 2366 1523
2006 4 19 15 23 0.60 8.57 1.23
2006 4 19 16
2006 4 19 17
2006 4 19 18 19 24 0.49 7.22 1.29 3679 350 1985 1345
2006 4 19 19 29 46 0.58 8.94 1.41 3934 233 2159 1541
2006 4 19 20 22 26 0.58 8.44 1.25 3546 209 2011 1326

Answers (1)

Harshit Saini
Harshit Saini on 27 Feb 2023
Edited: Harshit Saini on 27 Feb 2023
To select only the rows from which you have values in all columns of your dataset in MATLAB, you can use the "rmmissing" function. Here's an example code:
% load your dataset
load('your_data_file.mat');
% remove any rows that have missing values in any column
valid_data = rmmissing(data, 'MinNumMissing', 1);
In this code, we first load your dataset into a variable called data. We then use the "rmmissing" function to remove any rows that have missing values in any column. The 'MinNumMissing' option is set to 1 to ensure that only rows with at least one missing value are removed.
The "rmmissing" function returns a new dataset called valid_data that contains only the rows where all columns have non-missing values.
Refer to the documentation link below for more detailed examples

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!