ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 1 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| URL | https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan | |||||||||
| Last Crawled | 2026-03-24 17:31:24 (29 days ago) | |||||||||
| First Indexed | 2022-12-27 19:35:36 (3 years ago) | |||||||||
| HTTP Status Code | 200 | |||||||||
| Content | ||||||||||
| Meta Title | Remove Rows that are entirely NaN - MATLAB Answers - MATLAB Central | |||||||||
| Meta Description | Remove Rows that are entirely NaN. Learn more about machine learning, nan MATLAB | |||||||||
| Meta Canonical | null | |||||||||
| Boilerpipe Text | Hi,
I'm used to machine learning in Python, and I'm trying to get used to data cleaning to prepare a dataset for that in Matlab. I'm using the inflation dataset attached from the World Bank.
In short, I am trying to drop all rows that are completely null, because I need to be able to impute those NaNs, and eventually be able to attach my predictions to the same rows in the original dataset.
My process so far is to read the csv in as a table. drop all the text columns except for the country, reserve the orignal dataset for joining it back later, then normalize the data between 0 an 1 and then impute the nulls.
I've tried the following, but, I keep getting Incorrect number or types of inputs or outputs for function 'isnan'. error, and I'm not sure what I'm doing wrong.
N = table2cell(N);
N(cellfun(@(cell) any(isnan(cell(:))),N))={
''
};
empties = cellfun(
'isempty'
,N);
N(empties) = {NaN};
N(all(isnan(N),2),:) = [];
indices = find(N(:,2)==0);
N(indices,:) = [];
Original code, minus the removing rows that are NaNs
N = readtable(
'inflation.csv'
,
'NumHeaderLines'
,5);
N(:,[2,3,4]) = [];
n = N;
n(:,1) = [];
n = normalize(n,
'range'
);
n = knnimpute(n);
Accepted Answer
C = readcell(
'Inflation.csv'
)
N_header_lines = 3;
rows_to_delete = N_header_lines + find(all(cellfun(@ismissing,C(N_header_lines+1:end,5:end)),2));
C(rows_to_delete,:) = []
More Answers (2)
For tables, there is a very handy
rmmissing
function:
T = readtable(
"https://www.mathworks.com/matlabcentral/answers/uploaded_files/1241637/Inflation.csv"
,
'NumHeaderLines'
,5);
size(T)
ans =
266 66
R = rmmissing(T);
size(R)
ans =
66 66
Try this:
filename =
'Inflation.csv'
data = readmatrix(filename)
rowsToDelete = all(isnan(data), 2)
data(rowsToDelete, :) = []
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting! | |||||||||
| Markdown | [Skip to content](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#main)
[](https://www.mathworks.com/?s_tid=user_nav_logo)
[MATLAB Answers](https://www.mathworks.com/matlabcentral/answers/index)
- [MATLAB Help Center](https://www.mathworks.com/help/?s_tid=user_nav_help)
- [Community](https://www.mathworks.com/matlabcentral/?s_tid=user_nav_community)
- [Learning](https://matlabacademy.mathworks.com/?s_tid=user_nav_learning)
- [Get MATLAB](https://login.mathworks.com/embedded-login/landing.html?cid=getmatlab&s_tid=user_nav_getml)[MATLAB](https://login.mathworks.com/embedded-login/landing.html?cid=getmatlab&s_tid=user_nav_getml)
- [Sign In](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
- [My Account]()
- [My Community Profile]()
- [Link License]()
- ***
- [Sign Out]()
- [Contact MathWorks Support](https://www.mathworks.com/support/contact_us.html)
- [Visit mathworks.com](https://www.mathworks.com/)
- [MATLAB Answers](https://www.mathworks.com/matlabcentral/answers/index/?s_tid=gn_mlc_an)
- [File Exchange](https://www.mathworks.com/matlabcentral/fileexchange/?s_tid=gn_mlc_fx_files)
- [Cody](https://www.mathworks.com/matlabcentral/cody/?s_tid=gn_mlc_cody)
- [AI Chat Playground](https://www.mathworks.com/matlabcentral/playground?s_tid=gn_mlc_playground)
- [Discussions](https://www.mathworks.com/matlabcentral/discussions?s_tid=gn_mlc_disc)
- [Contests](https://www.mathworks.com/matlabcentral/contests.html?s_tid=gn_mlc_contests)
- [Blogs](https://blogs.mathworks.com/?s_tid=gn_mlc_blg)
- [More](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
- [Communities](https://www.mathworks.com/matlabcentral/content/communities.html?s_tid=gn_mlc_tbc_dl)
- [Treasure Hunt](https://www.mathworks.com/matlabcentral/community/onramps/mlc_treasure_hunt?s_tid=gn_mlc_hunt)
- [People](https://www.mathworks.com/matlabcentral/profile/authors/search?s_tid=gn_mlc_people)
- [Community Advisors](https://www.mathworks.com/matlabcentral/content/community-advisors.html?s_tid=gn_mlc_cab)
- [Virtual Badges](https://www.mathworks.com/matlabcentral/profile/badges/all?s_tid=gn_mlc_bdgs)
- [About](https://www.mathworks.com/matlabcentral/content/about.html?s_tid=gn_mlc_about)
- [Home](https://www.mathworks.com/matlabcentral/answers/index?s_tid=al)
- [Ask](https://www.mathworks.com/matlabcentral/answers/questions/new/?s_tid=gn_mlc_ans_ask)
- [Answer](https://www.mathworks.com/matlabcentral/answers/?status=unanswered&s_tid=gn_mlc_ans_ans)
- [Browse](https://www.mathworks.com/matlabcentral/answers/?s_tid=gn_mlc_ans_ans)
- [MATLAB FAQs](https://www.mathworks.com/matlabcentral/answers/faqs?s_tid=gn_mlc_ans_faqs)
- [More](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
- [Contributors](https://www.mathworks.com/matlabcentral/answers/contributors/?s_tid=gn_mlc_ans_cnt)
- [Recent Activity](https://www.mathworks.com/matlabcentral/answers/activities?s_tid=gn_mlc_ans_rec)
- [Flagged Content](https://www.mathworks.com/matlabcentral/answers/flagged?s_tid=gn_mlc_ans_FC)
- [Manage Spam](https://www.mathworks.com/matlabcentral/spammoderator?app=answers&s_tid=gn_mlc_ans_spam)
- [Help](https://www.mathworks.com/matlabcentral/answers/help?s_tid=gn_mlc_ans_hlp)
# Remove Rows that are entirely NaN
[](https://www.mathworks.com/matlabcentral/profile/authors/27475182)
[Tiffany](https://www.mathworks.com/matlabcentral/profile/authors/27475182)
23 Dec 2022
3 Answers
[Answer Accepted](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#answer_1135302)
[Updated 24 Dec 2022](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#question_1883812)
68 Views (30 days)
[Sign in to answer this question.](https://www.mathworks.com/login?uri=https%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fanswers%2F1883812-remove-rows-that-are-entirely-nan&form_type=community)
[Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#question_1883812_hdr)
[Follow Question](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
[Sign in to answer this question.](https://www.mathworks.com/login?uri=https%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fanswers%2F1883812-remove-rows-that-are-entirely-nan&form_type=community)
[Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#question_1883812_hdr_m)
[Follow Question](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
You are now following this question
- You will see updates in your [followed content feed](https://www.mathworks.com/matlabcentral/profile/authors/my_profile?content=all).
- You may receive emails, depending on your [communication preferences](https://www.mathworks.com/matlabcentral/profile/authors/my_profile/notification_preferences).
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Close
[Show older comments]()
[Open in MATLAB Online](https://matlab.mathworks.com/open/community/v1?mrn=mrn:community:v1:matlabanswers:question:1883812:)
0 votes
- [Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#question_1883812)
- [Translate](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
Share a link to this question
<https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan>
Cancel
Copy to Clipboard
- [Inflation.csv](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1241637/Inflation.csv)
Hi,
I'm used to machine learning in Python, and I'm trying to get used to data cleaning to prepare a dataset for that in Matlab. I'm using the inflation dataset attached from the World Bank.
In short, I am trying to drop all rows that are completely null, because I need to be able to impute those NaNs, and eventually be able to attach my predictions to the same rows in the original dataset.
My process so far is to read the csv in as a table. drop all the text columns except for the country, reserve the orignal dataset for joining it back later, then normalize the data between 0 an 1 and then impute the nulls.
I've tried the following, but, I keep getting Incorrect number or types of inputs or outputs for function 'isnan'. error, and I'm not sure what I'm doing wrong.
%drop rows that are entirely NaN
%testing
N = table2cell(N);
N(cellfun(@(cell) any(isnan(cell(:))),N))={''};
empties = cellfun('isempty',N);
N(empties) = {NaN};
N(all(isnan(N),2),:) = \[\];
indices = find(N(:,2)==0);
N(indices,:) = \[\];
%testing
% N = table2array(N);
% out = sum(N,2);
Original code, minus the removing rows that are NaNs
%read in inflation dataset from worldbank.org
N = readtable('inflation.csv','NumHeaderLines',5);
%drop cols 2-4. All text data.
N(:,\[2,3,4\]) = \[\];
%reserve the text data for joining later.
n = N;
n(:,1) = \[\];
%normalize the dataset for neural network
n = normalize(n, 'range');
%impute nulls with nearest neighbor method
%n = table2array(n);
%n(n=='NaN') = nan;
n = knnimpute(n);
## 0 Comments [Show -2 older comments Hide -2 older comments](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#toggle-comments)
[Sign in to comment.](https://www.mathworks.com/login?uri=https%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fanswers%2F1883812-remove-rows-that-are-entirely-nan&form_type=community)
[Sign in to answer this question.](https://www.mathworks.com/login?uri=https%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fanswers%2F1883812-remove-rows-that-are-entirely-nan&form_type=community)
[Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#question_1883812)
[Follow Question](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
## Accepted Answer
[](https://www.mathworks.com/matlabcentral/profile/authors/322333)
[Voss](https://www.mathworks.com/matlabcentral/profile/authors/322333) on 23 Dec 2022
[Ran in:](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
[Open in MATLAB Online](https://matlab.mathworks.com/open/community/v1?mrn=mrn:community:v1:matlabanswers:answer:1135302:)
1 vote
- [Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#answer_1135302)
- [Translate](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
Share a link to this answer
<https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#answer_1135302>
Cancel
Copy to Clipboard
[Ran in:](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
- [Inflation.csv](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1241637/Inflation.csv)
C = readcell('Inflation.csv')
C = 269×66 cell array
{'Data Source' } {'World Development Indicators'} {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {'Last Updated Date' } {\[22-Dec-2022 \]} {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {'Country Name' } {'Country Code' } {'Indicator Name' } {'Indicator Code'} {\[ 1960\]} {\[ 1961\]} {\[ 1962\]} {\[ 1963\]} {\[ 1964\]} {\[ 1965\]} {\[ 1966\]} {\[ 1967\]} {\[ 1968\]} {\[ 1969\]} {\[ 1970\]} {\[ 1971\]} {\[ 1972\]} {\[ 1973\]} {\[ 1974\]} {\[ 1975\]} {\[ 1976\]} {\[ 1977\]} {\[ 1978\]} {\[ 1979\]} {\[ 1980\]} {\[ 1981\]} {\[ 1982\]} {\[ 1983\]} {\[ 1984\]} {\[ 1985\]} {\[ 1986\]} {\[ 1987\]} {\[ 1988\]} {\[ 1989\]} {\[ 1990\]} {\[ 1991\]} {\[ 1992\]} {\[ 1993\]} {\[ 1994\]} {\[ 1995\]} {\[ 1996\]} {\[ 1997\]} {\[ 1998\]} {\[ 1999\]} {\[ 2000\]} {\[ 2001\]} {\[ 2002\]} {\[ 2003\]} {\[ 2004\]} {\[ 2005\]} {\[ 2006\]} {\[ 2007\]} {\[ 2008\]} {\[ 2009\]} {\[ 2010\]} {\[ 2011\]} {\[ 2012\]} {\[ 2013\]} {\[ 2014\]} {\[ 2015\]} {\[ 2016\]} {\[ 2017\]} {\[ 2018\]} {\[ 2019\]} {\[ 2020\]} {\[ 2021\]} {'Aruba' } {'ABW' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 4.0323\]} {\[ 1.0740\]} {\[ 3.6430\]} {\[ 3.1219\]} {\[ 3.9916\]} {\[ 5.8367\]} {\[ 5.5556\]} {\[ 3.8734\]} {\[ 5.2156\]} {\[ 6.3111\]} {\[ 3.3614\]} {\[ 3.2253\]} {\[ 2.9999\]} {\[ 1.8695\]} {\[ 2.2804\]} {\[ 4.0440\]} {\[ 2.8836\]} {\[ 3.3152\]} {\[ 3.6564\]} {\[ 2.5291\]} {\[ 3.3978\]} {\[ 3.6080\]} {\[ 5.3926\]} {\[ 8.9560\]} {\[ -2.1354\]} {\[ 2.0781\]} {\[ 4.3163\]} {\[ 0.6275\]} {\[ -2.3721\]} {\[ 0.4214\]} {\[ 0.4748\]} {\[ -0.9312\]} {\[ -1.0283\]} {\[ 3.6260\]} {\[ 4.2575\]} {1×1 missing} {1×1 missing} {'Africa Eastern and Southern'} {'AFE' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 19.5984\]} {\[ 15.2241\]} {\[ 11.2165\]} {\[ 14.2381\]} {\[ 12.5269\]} {\[ 15.0698\]} {\[ 15.0665\]} {\[ 14.4616\]} {\[ 12.1399\]} {\[ 11.5675\]} {\[ 10.9839\]} {\[ 13.0066\]} {\[ 13.8920\]} {\[ 12.5634\]} {\[ 12.5223\]} {\[ 12.5582\]} {\[ 12.4579\]} {\[ 17.6781\]} {\[ 16.1676\]} {\[ 13.1357\]} {\[ 14.8528\]} {\[ 12.2886\]} {\[ 9.7066\]} {\[ 10.2496\]} {\[ 7.4953\]} {\[ 7.8199\]} {\[ 8.6015\]} {\[ 5.8404\]} {\[ 8.7638\]} {\[ 7.4497\]} {\[ 5.0234\]} {\[ 8.5580\]} {\[ 8.8982\]} {\[ 8.4508\]} {\[ 12.5666\]} {\[ 8.9542\]} {\[ 5.5375\]} {\[ 8.9712\]} {\[ 9.1587\]} {\[ 5.7510\]} {\[ 5.3703\]} {\[ 5.2502\]} {\[ 6.5714\]} {\[ 6.3993\]} {\[ 4.7208\]} {\[ 4.1202\]} {\[ 6.3630\]} {\[ 6.0793\]} {'Afghanistan' } {'AFG' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 12.6863\]} {\[ 6.7846\]} {\[ 8.6806\]} {\[ 26.4187\]} {\[ -6.8112\]} {\[ 2.1785\]} {\[ 11.8042\]} {\[ 6.4412\]} {\[ 7.3858\]} {\[ 4.6740\]} {\[ -0.6617\]} {\[ 4.3839\]} {\[ 4.9760\]} {\[ 0.6261\]} {\[ 2.3024\]} {1×1 missing} {1×1 missing} {'Africa Western and Central' } {'AFW' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 8.7992\]} {\[ 12.0598\]} {\[ 10.6719\]} {\[ 11.2500\]} {\[ 7.3549\]} {\[ 5.9510\]} {\[ 0.2488\]} {\[ 2.5237\]} {\[ 0.8693\]} {\[ 1.0574\]} {\[ 1.7419\]} {\[ -0.0630\]} {\[ 0.5535\]} {\[ 31.8410\]} {\[ 10.5633\]} {\[ 4.9142\]} {\[ 3.9971\]} {\[ 4.4711\]} {\[ 0.3723\]} {\[ 2.5308\]} {\[ 4.3615\]} {\[ 3.1887\]} {\[ 1.7609\]} {\[ 0.6943\]} {\[ 5.6316\]} {\[ 4.4159\]} {\[ 3.6074\]} {\[ 8.4530\]} {\[ 3.2824\]} {\[ 1.7848\]} {\[ 4.0187\]} {\[ 4.5784\]} {\[ 2.4392\]} {\[ 1.7581\]} {\[ 2.1303\]} {\[ 1.4946\]} {\[ 1.7646\]} {\[ 1.7840\]} {\[ 1.7586\]} {\[ 2.4376\]} {\[ 3.8379\]} {'Angola' } {'AGO' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 83.7838\]} {\[ 299.5098\]} {\[1.3785e+03\]} {\[ 949.7925\]} {\[2.6665e+03\]} {\[4.1451e+03\]} {\[ 219.1767\]} {\[ 107.2848\]} {\[ 248.1959\]} {\[ 324.9969\]} {\[ 152.5610\]} {\[ 108.8974\]} {\[ 98.2241\]} {\[ 43.5421\]} {\[ 22.9535\]} {\[ 13.3052\]} {\[ 12.2515\]} {\[ 12.4758\]} {\[ 13.7303\]} {\[ 14.4697\]} {\[ 13.4825\]} {\[ 10.2779\]} {\[ 8.7778\]} {\[ 7.2804\]} {\[ 9.3538\]} {\[ 30.6990\]} {\[ 29.8426\]} {\[ 19.6306\]} {\[ 17.0797\]} {\[ 22.2716\]} {\[ 25.7543\]} {'Albania' } {'ALB' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 226.0054\]} {\[ 85.0048\]} {\[ 22.5651\]} {\[ 7.7932\]} {\[ 12.7255\]} {\[ 33.1803\]} {\[ 20.6429\]} {\[ 0.3894\]} {\[ 0.0500\]} {\[ 3.1076\]} {\[ 7.7705\]} {\[ 0.4840\]} {\[ 2.2800\]} {\[ 2.3666\]} {\[ 2.3707\]} {\[ 2.9327\]} {\[ 3.3209\]} {\[ 2.2669\]} {\[ 3.6260\]} {\[ 3.4291\]} {\[ 2.0316\]} {\[ 1.9376\]} {\[ 1.6259\]} {\[ 3.5012\]} {\[ -0.3673\]} {\[ 2.0606\]} {\[ 2.0281\]} {\[ 1.4111\]} {\[ 1.6209\]} {\[ 2.0415\]} {'Andorra' } {'AND' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {'Arab World' } {'ARB' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 8.2667\]} {\[ 15.5283\]} {\[ 9.6697\]} {\[ 10.3174\]} {\[ 11.9893\]} {\[ 9.7160\]} {1×1 missing} {\[ 9.6261\]} {\[ 10.7585\]} {\[ 8.3313\]} {\[ 5.4937\]} {\[ 8.1164\]} {\[ 7.2544\]} {\[ 6.7989\]} {\[ 4.2224\]} {\[ 5.9115\]} {\[ 7.7409\]} {\[ 8.4515\]} {\[ 9.0000\]} {\[ 9.3598\]} {\[ 9.3703\]} {\[ 5.1126\]} {\[ 6.5438\]} {\[ 4.6813\]} {\[ 3.6012\]} {\[ 3.4173\]} {\[ 2.6694\]} {\[ 1.8538\]} {\[ 1.7722\]} {\[ 1.8330\]} {\[ 2.7126\]} {\[ 3.6323\]} {\[ 3.4937\]} {\[ 3.5450\]} {\[ 4.7439\]} {\[ 11.2707\]} {\[ 2.9209\]} {\[ 3.9111\]} {\[ 4.7532\]} {\[ 4.6118\]} {\[ 3.2381\]} {\[ 2.7735\]} {\[ 1.8141\]} {\[ 2.0688\]} {\[ 1.9668\]} {\[ 2.4581\]} {\[ 1.0918\]} {\[ 1.7774\]} {\[ 3.4236\]} {'United Arab Emirates' } {'ARE' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 12.2504\]} {\[ 1.5618\]} {\[ 0.8780\]} {\[ 0.8773\]} {\[ 0.6623\]} {\[ 1.1011\]} {\[ 2.3463\]} {\[ 4.0700\]} {\[ 1.6175\]} {\[ 1.9668\]} {\[ 3.0686\]} {\[ -1.9311\]} {\[ -2.0794\]} {1×1 missing} {'Argentina' } {'ARG' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {'Armenia' } {'ARM' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {\[3.3738e+03\]} {\[ 175.9513\]} {\[ 18.6812\]} {\[ 13.9608\]} {\[ 8.6725\]} {\[ 0.6482\]} {\[ -0.7909\]} {\[ 3.1459\]} {\[ 1.0600\]} {\[ 4.7216\]} {\[ 6.9613\]} {\[ 0.6389\]} {\[ 2.8924\]} {\[ 4.4074\]} {\[ 8.9500\]} {\[ 3.4068\]} {\[ 8.1764\]} {\[ 7.6500\]} {\[ 2.5580\]} {\[ 5.7897\]} {\[ 2.9813\]} {\[ 3.7317\]} {\[ -1.4036\]} {\[ 0.9696\]} {\[ 2.5202\]} {\[ 1.4434\]} {\[ 1.2114\]} {\[ 7.1848\]} {'American Samoa' } {'ASM' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {'Antigua and Barbuda' } {'ATG' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {\[ 1.1213\]} {\[ 0.7718\]} {\[ 1.4028\]} {\[ 2.4077\]} {\[ 1.9935\]} {\[ 2.0301\]} {\[ 2.0988\]} {\[ 1.7878\]} {\[ 1.4161\]} {\[ 5.3338\]} {\[ -0.5502\]} {\[ 3.3700\]} {\[ 3.4567\]} {\[ 3.3769\]} {\[ 1.0595\]} {\[ 1.0894\]} {\[ 0.9690\]} {\[ -0.4894\]} {\[ 2.4325\]} {\[ 1.2072\]} {\[ 1.4314\]} {\[ 0.6260\]} {\[ 2.0630\]}
N\_header\_lines = 3;
rows\_to\_delete = N\_header\_lines + find(all(cellfun(@ismissing,C(N\_header\_lines+1:end,5:end)),2));
C(rows\_to\_delete,:) = \[\]
C = 243×66 cell array
{'Data Source' } {'World Development Indicators'} {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {'Last Updated Date' } {\[22-Dec-2022 \]} {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {'Country Name' } {'Country Code' } {'Indicator Name' } {'Indicator Code'} {\[ 1960\]} {\[ 1961\]} {\[ 1962\]} {\[ 1963\]} {\[ 1964\]} {\[ 1965\]} {\[ 1966\]} {\[ 1967\]} {\[ 1968\]} {\[ 1969\]} {\[ 1970\]} {\[ 1971\]} {\[ 1972\]} {\[ 1973\]} {\[ 1974\]} {\[ 1975\]} {\[ 1976\]} {\[ 1977\]} {\[ 1978\]} {\[ 1979\]} {\[ 1980\]} {\[ 1981\]} {\[ 1982\]} {\[ 1983\]} {\[ 1984\]} {\[ 1985\]} {\[ 1986\]} {\[ 1987\]} {\[ 1988\]} {\[ 1989\]} {\[ 1990\]} {\[ 1991\]} {\[ 1992\]} {\[ 1993\]} {\[ 1994\]} {\[ 1995\]} {\[ 1996\]} {\[ 1997\]} {\[ 1998\]} {\[ 1999\]} {\[ 2000\]} {\[ 2001\]} {\[ 2002\]} {\[ 2003\]} {\[ 2004\]} {\[ 2005\]} {\[ 2006\]} {\[ 2007\]} {\[ 2008\]} {\[ 2009\]} {\[ 2010\]} {\[ 2011\]} {\[ 2012\]} {\[ 2013\]} {\[ 2014\]} {\[ 2015\]} {\[ 2016\]} {\[ 2017\]} {\[ 2018\]} {\[ 2019\]} {\[ 2020\]} {\[ 2021\]} {'Aruba' } {'ABW' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 4.0323\]} {\[ 1.0740\]} {\[ 3.6430\]} {\[ 3.1219\]} {\[ 3.9916\]} {\[ 5.8367\]} {\[ 5.5556\]} {\[ 3.8734\]} {\[ 5.2156\]} {\[ 6.3111\]} {\[ 3.3614\]} {\[ 3.2253\]} {\[ 2.9999\]} {\[ 1.8695\]} {\[ 2.2804\]} {\[ 4.0440\]} {\[ 2.8836\]} {\[ 3.3152\]} {\[ 3.6564\]} {\[ 2.5291\]} {\[ 3.3978\]} {\[ 3.6080\]} {\[ 5.3926\]} {\[ 8.9560\]} {\[ -2.1354\]} {\[ 2.0781\]} {\[ 4.3163\]} {\[ 0.6275\]} {\[ -2.3721\]} {\[ 0.4214\]} {\[ 0.4748\]} {\[ -0.9312\]} {\[ -1.0283\]} {\[ 3.6260\]} {\[ 4.2575\]} {1×1 missing} {1×1 missing} {'Africa Eastern and Southern'} {'AFE' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 19.5984\]} {\[ 15.2241\]} {\[ 11.2165\]} {\[ 14.2381\]} {\[ 12.5269\]} {\[ 15.0698\]} {\[ 15.0665\]} {\[ 14.4616\]} {\[ 12.1399\]} {\[ 11.5675\]} {\[ 10.9839\]} {\[ 13.0066\]} {\[ 13.8920\]} {\[ 12.5634\]} {\[ 12.5223\]} {\[ 12.5582\]} {\[ 12.4579\]} {\[ 17.6781\]} {\[ 16.1676\]} {\[ 13.1357\]} {\[ 14.8528\]} {\[ 12.2886\]} {\[ 9.7066\]} {\[ 10.2496\]} {\[ 7.4953\]} {\[ 7.8199\]} {\[ 8.6015\]} {\[ 5.8404\]} {\[ 8.7638\]} {\[ 7.4497\]} {\[ 5.0234\]} {\[ 8.5580\]} {\[ 8.8982\]} {\[ 8.4508\]} {\[ 12.5666\]} {\[ 8.9542\]} {\[ 5.5375\]} {\[ 8.9712\]} {\[ 9.1587\]} {\[ 5.7510\]} {\[ 5.3703\]} {\[ 5.2502\]} {\[ 6.5714\]} {\[ 6.3993\]} {\[ 4.7208\]} {\[ 4.1202\]} {\[ 6.3630\]} {\[ 6.0793\]} {'Afghanistan' } {'AFG' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 12.6863\]} {\[ 6.7846\]} {\[ 8.6806\]} {\[ 26.4187\]} {\[ -6.8112\]} {\[ 2.1785\]} {\[ 11.8042\]} {\[ 6.4412\]} {\[ 7.3858\]} {\[ 4.6740\]} {\[ -0.6617\]} {\[ 4.3839\]} {\[ 4.9760\]} {\[ 0.6261\]} {\[ 2.3024\]} {1×1 missing} {1×1 missing} {'Africa Western and Central' } {'AFW' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 8.7992\]} {\[ 12.0598\]} {\[ 10.6719\]} {\[ 11.2500\]} {\[ 7.3549\]} {\[ 5.9510\]} {\[ 0.2488\]} {\[ 2.5237\]} {\[ 0.8693\]} {\[ 1.0574\]} {\[ 1.7419\]} {\[ -0.0630\]} {\[ 0.5535\]} {\[ 31.8410\]} {\[ 10.5633\]} {\[ 4.9142\]} {\[ 3.9971\]} {\[ 4.4711\]} {\[ 0.3723\]} {\[ 2.5308\]} {\[ 4.3615\]} {\[ 3.1887\]} {\[ 1.7609\]} {\[ 0.6943\]} {\[ 5.6316\]} {\[ 4.4159\]} {\[ 3.6074\]} {\[ 8.4530\]} {\[ 3.2824\]} {\[ 1.7848\]} {\[ 4.0187\]} {\[ 4.5784\]} {\[ 2.4392\]} {\[ 1.7581\]} {\[ 2.1303\]} {\[ 1.4946\]} {\[ 1.7646\]} {\[ 1.7840\]} {\[ 1.7586\]} {\[ 2.4376\]} {\[ 3.8379\]} {'Angola' } {'AGO' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 83.7838\]} {\[ 299.5098\]} {\[1.3785e+03\]} {\[ 949.7925\]} {\[2.6665e+03\]} {\[4.1451e+03\]} {\[ 219.1767\]} {\[ 107.2848\]} {\[ 248.1959\]} {\[ 324.9969\]} {\[ 152.5610\]} {\[ 108.8974\]} {\[ 98.2241\]} {\[ 43.5421\]} {\[ 22.9535\]} {\[ 13.3052\]} {\[ 12.2515\]} {\[ 12.4758\]} {\[ 13.7303\]} {\[ 14.4697\]} {\[ 13.4825\]} {\[ 10.2779\]} {\[ 8.7778\]} {\[ 7.2804\]} {\[ 9.3538\]} {\[ 30.6990\]} {\[ 29.8426\]} {\[ 19.6306\]} {\[ 17.0797\]} {\[ 22.2716\]} {\[ 25.7543\]} {'Albania' } {'ALB' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 226.0054\]} {\[ 85.0048\]} {\[ 22.5651\]} {\[ 7.7932\]} {\[ 12.7255\]} {\[ 33.1803\]} {\[ 20.6429\]} {\[ 0.3894\]} {\[ 0.0500\]} {\[ 3.1076\]} {\[ 7.7705\]} {\[ 0.4840\]} {\[ 2.2800\]} {\[ 2.3666\]} {\[ 2.3707\]} {\[ 2.9327\]} {\[ 3.3209\]} {\[ 2.2669\]} {\[ 3.6260\]} {\[ 3.4291\]} {\[ 2.0316\]} {\[ 1.9376\]} {\[ 1.6259\]} {\[ 3.5012\]} {\[ -0.3673\]} {\[ 2.0606\]} {\[ 2.0281\]} {\[ 1.4111\]} {\[ 1.6209\]} {\[ 2.0415\]} {'Arab World' } {'ARB' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 8.2667\]} {\[ 15.5283\]} {\[ 9.6697\]} {\[ 10.3174\]} {\[ 11.9893\]} {\[ 9.7160\]} {1×1 missing} {\[ 9.6261\]} {\[ 10.7585\]} {\[ 8.3313\]} {\[ 5.4937\]} {\[ 8.1164\]} {\[ 7.2544\]} {\[ 6.7989\]} {\[ 4.2224\]} {\[ 5.9115\]} {\[ 7.7409\]} {\[ 8.4515\]} {\[ 9.0000\]} {\[ 9.3598\]} {\[ 9.3703\]} {\[ 5.1126\]} {\[ 6.5438\]} {\[ 4.6813\]} {\[ 3.6012\]} {\[ 3.4173\]} {\[ 2.6694\]} {\[ 1.8538\]} {\[ 1.7722\]} {\[ 1.8330\]} {\[ 2.7126\]} {\[ 3.6323\]} {\[ 3.4937\]} {\[ 3.5450\]} {\[ 4.7439\]} {\[ 11.2707\]} {\[ 2.9209\]} {\[ 3.9111\]} {\[ 4.7532\]} {\[ 4.6118\]} {\[ 3.2381\]} {\[ 2.7735\]} {\[ 1.8141\]} {\[ 2.0688\]} {\[ 1.9668\]} {\[ 2.4581\]} {\[ 1.0918\]} {\[ 1.7774\]} {\[ 3.4236\]} {'United Arab Emirates' } {'ARE' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ 12.2504\]} {\[ 1.5618\]} {\[ 0.8780\]} {\[ 0.8773\]} {\[ 0.6623\]} {\[ 1.1011\]} {\[ 2.3463\]} {\[ 4.0700\]} {\[ 1.6175\]} {\[ 1.9668\]} {\[ 3.0686\]} {\[ -1.9311\]} {\[ -2.0794\]} {1×1 missing} {'Armenia' } {'ARM' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {\[3.3738e+03\]} {\[ 175.9513\]} {\[ 18.6812\]} {\[ 13.9608\]} {\[ 8.6725\]} {\[ 0.6482\]} {\[ -0.7909\]} {\[ 3.1459\]} {\[ 1.0600\]} {\[ 4.7216\]} {\[ 6.9613\]} {\[ 0.6389\]} {\[ 2.8924\]} {\[ 4.4074\]} {\[ 8.9500\]} {\[ 3.4068\]} {\[ 8.1764\]} {\[ 7.6500\]} {\[ 2.5580\]} {\[ 5.7897\]} {\[ 2.9813\]} {\[ 3.7317\]} {\[ -1.4036\]} {\[ 0.9696\]} {\[ 2.5202\]} {\[ 1.4434\]} {\[ 1.2114\]} {\[ 7.1848\]} {'Antigua and Barbuda' } {'ATG' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing } {1×1 missing} {1×1 missing} {\[ 1.1213\]} {\[ 0.7718\]} {\[ 1.4028\]} {\[ 2.4077\]} {\[ 1.9935\]} {\[ 2.0301\]} {\[ 2.0988\]} {\[ 1.7878\]} {\[ 1.4161\]} {\[ 5.3338\]} {\[ -0.5502\]} {\[ 3.3700\]} {\[ 3.4567\]} {\[ 3.3769\]} {\[ 1.0595\]} {\[ 1.0894\]} {\[ 0.9690\]} {\[ -0.4894\]} {\[ 2.4325\]} {\[ 1.2072\]} {\[ 1.4314\]} {\[ 0.6260\]} {\[ 2.0630\]} {'Australia' } {'AUS' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {\[ 3.7288\]} {\[ 2.2876\]} {\[ -0.3195\]} {\[ 0.6410\]} {\[ 2.8662\]} {\[ 3.4056\]} {\[ 3.2934\]} {\[ 3.4783\]} {\[ 2.5210\]} {\[ 3.2787\]} {\[ 3.4392\]} {\[ 6.1381\]} {\[ 6.0241\]} {\[ 9.0909\]} {\[ 15.4167\]} {\[ 15.1625\]} {\[ 13.3229\]} {\[ 12.3098\]} {\[ 8.0049\]} {\[ 9.1220\]} {\[ 10.1358\]} {\[ 9.4877\]} {\[ 11.3518\]} {\[ 10.0389\]} {\[ 3.9604\]} {\[ 6.7347\]} {\[ 9.0504\]} {\[ 8.5330\]} {\[ 7.2159\]} {\[ 7.5339\]} {\[ 7.3330\]} {\[ 3.1767\]} {\[ 1.0122\]} {\[ 1.7537\]} {\[ 1.9696\]} {\[ 4.6278\]} {\[ 2.6154\]} {\[ 0.2249\]} {\[ 0.8601\]} {\[ 1.4831\]} {\[ 4.4574\]} {\[ 4.4071\]} {\[ 2.9816\]} {\[ 2.7326\]} {\[ 2.3433\]} {\[ 2.6918\]} {\[ 3.5553\]} {\[ 2.3276\]} {\[ 4.3503\]} {\[ 1.7711\]} {\[ 2.9183\]} {\[ 3.3039\]} {\[ 1.7628\]} {\[ 2.4499\]} {\[ 2.4879\]} {\[ 1.5084\]} {\[ 1.2770\]} {\[ 1.9486\]} {\[ 1.9114\]} {\[ 1.6108\]} {\[ 0.8469\]} {\[ 2.8639\]} {'Austria' } {'AUT' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {\[ 1.9457\]} {\[ 3.5422\]} {\[ 4.3818\]} {\[ 2.7088\]} {\[ 3.8686\]} {\[ 4.9309\]} {\[ 2.0548\]} {\[ 3.9747\]} {\[ 2.7649\]} {\[ 3.0804\]} {\[ 4.3728\]} {\[ 4.7043\]} {\[ 6.3551\]} {\[ 7.5311\]} {\[ 9.5218\]} {\[ 8.4453\]} {\[ 7.3187\]} {\[ 5.4946\]} {\[ 3.5743\]} {\[ 3.7074\]} {\[ 6.3283\]} {\[ 6.8030\]} {\[ 5.4360\]} {\[ 3.3392\]} {\[ 5.6632\]} {\[ 3.1895\]} {\[ 1.7054\]} {\[ 1.4020\]} {\[ 1.9157\]} {\[ 2.5683\]} {\[ 3.2619\]} {\[ 3.3374\]} {\[ 4.0208\]} {\[ 3.6318\]} {\[ 2.9534\]} {\[ 2.2434\]} {\[ 1.8610\]} {\[ 1.3060\]} {\[ 0.9225\]} {\[ 0.5690\]} {\[ 2.3449\]} {\[ 2.6500\]} {\[ 1.8104\]} {\[ 1.3556\]} {\[ 2.0612\]} {\[ 2.2991\]} {\[ 1.4415\]} {\[ 2.1686\]} {\[ 3.2160\]} {\[ 0.5063\]} {\[ 1.8135\]} {\[ 3.2866\]} {\[ 2.4857\]} {\[ 2.0002\]} {\[ 1.6058\]} {\[ 0.8966\]} {\[ 0.8916\]} {\[ 2.0813\]} {\[ 1.9984\]} {\[ 1.5309\]} {\[ 1.3819\]} {\[ 2.7667\]} {'Azerbaijan' } {'AZE' } {'Inflation, consumer prices (annual %)'} {'FP.CPI.TOTL.ZG'} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {1×1 missing} {\[ -10.6301\]} {\[1.1280e+03\]} {\[1.6622e+03\]} {\[ 411.7596\]} {\[ 19.7948\]} {\[ 3.6743\]} {\[ -0.7727\]} {\[ -8.5252\]} {\[ 1.8050\]} {\[ 1.5472\]} {\[ 2.7712\]} {\[ 2.2339\]} {\[ 6.7089\]} {\[ 9.6795\]} {\[ 8.3289\]} {\[ 16.6998\]} {\[ 20.8491\]} {\[ 1.4570\]} {\[ 5.7269\]} {\[ 7.8583\]} {\[ 1.0662\]} {\[ 2.4157\]} {\[ 1.3734\]} {\[ 4.0277\]} {\[ 12.4434\]} {\[ 12.9359\]} {\[ 2.2685\]} {\[ 2.6106\]} {\[ 2.7598\]} {\[ 6.6503\]}
## 2 Comments [Show None Hide None](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#toggle-comments)
[](https://www.mathworks.com/matlabcentral/profile/authors/27475182)
[Tiffany](https://www.mathworks.com/matlabcentral/profile/authors/27475182) on 24 Dec 2022
- [Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533517)
- [Translate](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
Share a link to this comment
<https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533517>
Cancel
Copy to Clipboard
Thank you, this worked best for me.
[](https://www.mathworks.com/matlabcentral/profile/authors/1343420)
[Image Analyst](https://www.mathworks.com/matlabcentral/profile/authors/1343420) on 24 Dec 2022
- [Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533522)
- [Translate](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
Share a link to this comment
<https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533522>
Cancel
Copy to Clipboard
Not sure you even saw my answer, but anyway...
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.
[Sign in to comment.](https://www.mathworks.com/login?uri=https%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fanswers%2F1883812-remove-rows-that-are-entirely-nan&form_type=community)
## More Answers (2)
[](https://www.mathworks.com/matlabcentral/profile/authors/1841757)
[the cyclist](https://www.mathworks.com/matlabcentral/profile/authors/1841757) on 23 Dec 2022
Edited: [the cyclist](https://www.mathworks.com/matlabcentral/profile/authors/1841757) on 23 Dec 2022
[Ran in:](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
[Open in MATLAB Online](https://matlab.mathworks.com/open/community/v1?mrn=mrn:community:v1:matlabanswers:answer:1135257:)
0 votes
- [Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#answer_1135257)
- [Translate](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
Share a link to this answer
<https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#answer_1135257>
Cancel
Copy to Clipboard
[Ran in:](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
For tables, there is a very handy [rmmissing](https://www.mathworks.com/help/matlab/ref/rmmissing.html) function:
% I am reading from the file you posted here, but you can of course read your local file
T = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded\_files/1241637/Inflation.csv",'NumHeaderLines',5);
size(T)
ans = 1×2
266 66
R = rmmissing(T);
size(R)
ans = 1×2
66 66
## 3 Comments [Show 1 older comment Hide 1 older comment](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#toggle-comments)
[](https://www.mathworks.com/matlabcentral/profile/authors/27475182)
[Tiffany](https://www.mathworks.com/matlabcentral/profile/authors/27475182) on 23 Dec 2022
- [Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533087)
- [Translate](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
Share a link to this comment
<https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533087>
Cancel
Copy to Clipboard
Hi There,
Thanks for trying to help with this. It seems to remove any row with a null, rather than rows with all nulls, so it might not be the way for me to go. I appreciate you trying to help though.
[](https://www.mathworks.com/matlabcentral/profile/authors/1841757)
[the cyclist](https://www.mathworks.com/matlabcentral/profile/authors/1841757) on 24 Dec 2022
- [Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533122)
- [Translate](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
Share a link to this comment
<https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533122>
Cancel
Copy to Clipboard
Ah, sorry, I misread what you wanted to do
[](https://www.mathworks.com/matlabcentral/profile/authors/1841757)
[the cyclist](https://www.mathworks.com/matlabcentral/profile/authors/1841757) on 24 Dec 2022
[Ran in:](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
[Open in MATLAB Online](https://matlab.mathworks.com/open/community/v1?mrn=mrn:community:v1:matlabanswers:comment:2533132:)
- [Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533132)
- [Translate](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
Share a link to this comment
<https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533132>
Cancel
Copy to Clipboard
[Ran in:](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
You can still use this command, if you use the Name-Value pair to specify the minimum number of missing elements needed to warrant row removal. For example,
T = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded\_files/1241637/Inflation.csv",'NumHeaderLines',5);
size(T)
ans = 1×2
266 66
R = rmmissing(T,'MinNumMissing',62);
size(R)
ans = 1×2
240 66
[Sign in to comment.](https://www.mathworks.com/login?uri=https%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fanswers%2F1883812-remove-rows-that-are-entirely-nan&form_type=community)
[](https://www.mathworks.com/matlabcentral/profile/authors/1343420)
[Image Analyst](https://www.mathworks.com/matlabcentral/profile/authors/1343420) on 23 Dec 2022
[Open in MATLAB Online](https://matlab.mathworks.com/open/community/v1?mrn=mrn:community:v1:matlabanswers:answer:1135292:)
0 votes
- [Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#answer_1135292)
- [Translate](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
Share a link to this answer
<https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#answer_1135292>
Cancel
Copy to Clipboard
Try this:
filename = 'Inflation.csv'
data = readmatrix(filename)
rowsToDelete = all(isnan(data), 2) % Rows where all columns are nan.
data(rowsToDelete, :) = \[\] % Delete those rows.
## 3 Comments [Show 1 older comment Hide 1 older comment](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#toggle-comments)
[](https://www.mathworks.com/matlabcentral/profile/authors/1343420)
[Image Analyst](https://www.mathworks.com/matlabcentral/profile/authors/1343420) on 24 Dec 2022
Edited: [Image Analyst](https://www.mathworks.com/matlabcentral/profile/authors/1343420) on 24 Dec 2022
[Open in MATLAB Online](https://matlab.mathworks.com/open/community/v1?mrn=mrn:community:v1:matlabanswers:comment:2533397:)
- [Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533397)
- [Translate](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
Share a link to this comment
<https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533397>
Cancel
Copy to Clipboard
You said in your question title "Remove Rows that are entirely NaN" so that's why I used all(). To most of use entirely means all.
If you now want "to remove any row with a null, rather than rows with all nulls" then you should use any() rather than all():
filename = 'Inflation.csv'
data = readmatrix(filename)
rowsToDelete = any(isnan(data), 2) % Rows where any columns are nan.
data(rowsToDelete, :) = \[\] % Delete those rows.
[](https://www.mathworks.com/matlabcentral/profile/authors/27475182)
[Tiffany](https://www.mathworks.com/matlabcentral/profile/authors/27475182) on 24 Dec 2022
- [Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533567)
- [Translate](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
Share a link to this comment
<https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533567>
Cancel
Copy to Clipboard
Hi there,
Thank you for this. The readmatrix eliminated too much data that I need to retain for later, but thank you.
[](https://www.mathworks.com/matlabcentral/profile/authors/1343420)
[Image Analyst](https://www.mathworks.com/matlabcentral/profile/authors/1343420) on 24 Dec 2022
[Open in MATLAB Online](https://matlab.mathworks.com/open/community/v1?mrn=mrn:community:v1:matlabanswers:comment:2533577:)
- [Share](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533577)
- [Translate](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
Share a link to this comment
<https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#comment_2533577>
Cancel
Copy to Clipboard
- [Inflation.csv](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1241982/Inflation.csv)
The usual recommendation is to avoid cell arrays if at all possible, in favor of a table. In your case you can use a table. Here is my code adapted to read your data into a table and remove any rows with a nan in them:
filename = 'Inflation.csv'
t = readtable(filename); % Read into table.
data = table2array(t(:, 5:end));
rowsToDelete = any(isnan(data), 2) % Rows where any columns are nan.
t(rowsToDelete, :) = \[\] % Delete those rows.
[Sign in to comment.](https://www.mathworks.com/login?uri=https%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fanswers%2F1883812-remove-rows-that-are-entirely-nan&form_type=community)
[Sign in to answer this question.](https://www.mathworks.com/login?uri=https%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fanswers%2F1883812-remove-rows-that-are-entirely-nan&form_type=community)
### Categories
1. [MATLAB](https://www.mathworks.com/matlabcentral/answers/?category=matlab%2Findex&s_tid=ans_search_cat)
2. [Language Fundamentals](https://www.mathworks.com/matlabcentral/answers/?category=matlab%2Findex.matlab%2Flanguage-fundamentals&s_tid=ans_search_cat)
3. [Data Types](https://www.mathworks.com/matlabcentral/answers/?category=matlab%2Findex.matlab%2Flanguage-fundamentals.matlab%2Fdata-types&s_tid=ans_search_cat)
4. [Data Type Identification](https://www.mathworks.com/matlabcentral/answers/?category=matlab%2Findex.matlab%2Flanguage-fundamentals.matlab%2Fdata-types.matlab%2Fdata-type-identification&s_tid=ans_search_cat)
Find more on **Data Type Identification** in [Help Center](https://www.mathworks.com/support/search.html?fq[]=category:matlab/data-type-identification&s_tid=answers_leaf_hc_category) and [File Exchange](https://www.mathworks.com/matlabcentral/fileexchange/?category[]=matlab/index.matlab/language-fundamentals.matlab/data-types.matlab/data-type-identification&s_tid=answers_leaf_fx_category)
### Products
- [MATLAB](https://www.mathworks.com/matlabcentral/answers/?term=product_base_code%3A%22MATLAB%22)
### Release
R2022b
### Tags
- [machine learning](https://www.mathworks.com/matlabcentral/answers/?term=tag%3A%22machine+learning%22 "machine learning")
- [nan](https://www.mathworks.com/matlabcentral/answers/?term=tag%3A%22nan%22 "nan")
## See Also
[Asked:](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
[](https://www.mathworks.com/matlabcentral/profile/authors/27475182)
[Tiffany](https://www.mathworks.com/matlabcentral/profile/authors/27475182)
on 23 Dec 2022
[Edited:](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#question_1883812)
[](https://www.mathworks.com/matlabcentral/profile/authors/434782)
[Walter Roberson](https://www.mathworks.com/matlabcentral/profile/authors/434782)
on 24 Dec 2022
[Accepted:](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan#answer_1135302)
[](https://www.mathworks.com/matlabcentral/profile/authors/322333)
[Voss](https://www.mathworks.com/matlabcentral/profile/authors/322333)
### Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you\!
[Start Hunting\!](https://www.mathworks.com/matlabcentral/community/onramps/mlc_treasure_hunt?s_tid=hunt_spotlight)

Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
- [(English)](https://ch.mathworks.com/)
- [(Deutsch)](https://ch.mathworks.com/)
- [(Français)](https://ch.mathworks.com/)
- [(简体中文)](https://ww2.mathworks.cn/)
- [(English)](https://ww2.mathworks.cn/)
You can also select a web site from the following list
**How to Get Best Site Performance**
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- [América Latina](https://la.mathworks.com/) (Español)
- [Canada](https://www.mathworks.com/) (English)
- [United States](https://www.mathworks.com/) (English)
Europe
- [Belgium](https://nl.mathworks.com/) (English)
- [Denmark](https://se.mathworks.com/) (English)
- [Deutschland](https://de.mathworks.com/) (Deutsch)
- [España](https://es.mathworks.com/) (Español)
- [Finland](https://se.mathworks.com/) (English)
- [France](https://fr.mathworks.com/) (Français)
- [Ireland](https://uk.mathworks.com/) (English)
- [Italia](https://it.mathworks.com/) (Italiano)
- [Luxembourg](https://nl.mathworks.com/) (English)
- [Netherlands](https://nl.mathworks.com/) (English)
- [Norway](https://se.mathworks.com/) (English)
- [Österreich](https://de.mathworks.com/) (Deutsch)
- [Portugal](https://www.mathworks.com/) (English)
- [Sweden](https://se.mathworks.com/) (English)
- Switzerland
- [Deutsch](https://ch.mathworks.com/)
- [English](https://ch.mathworks.com/)
- [Français](https://ch.mathworks.com/)
- [United Kingdom](https://uk.mathworks.com/) (English)
Asia Pacific
- [Australia](https://au.mathworks.com/) (English)
- [India](https://in.mathworks.com/) (English)
- [New Zealand](https://au.mathworks.com/) (English)
- 中国
- [简体中文](https://ww2.mathworks.cn/)
- [English](https://ww2.mathworks.cn/)
- [日本](https://jp.mathworks.com/) (日本語)
- [한국](https://kr.mathworks.com/) (한국어)
[Contact your local office](https://www.mathworks.com/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan)
- [Trust Center](https://www.mathworks.com/company/aboutus/policies_statements/trust-center.html?s_tid=gf_tc)
- [Trademarks](https://www.mathworks.com/company/aboutus/policies_statements/trademarks.html?s_tid=gf_trd)
- [Privacy Policy](https://www.mathworks.com/company/aboutus/policies_statements.html?s_tid=gf_priv)
- [Preventing Piracy](https://www.mathworks.com/company/aboutus/policies_statements/piracy.html?s_tid=gf_pir)
- [Application Status](https://status.mathworks.com/?s_tid=gf_application)
- [Terms of Use](https://www.mathworks.com/matlabcentral/content/terms-of-use.html?s_tid=gf_terms)
- [Contact Us](https://www.mathworks.com/company/aboutus/contact_us.html?s_tid=gf_contact)
© 1994-2026 The MathWorks, Inc.
Select a Web SiteUnited States | |||||||||
| Readable Markdown | Hi,
I'm used to machine learning in Python, and I'm trying to get used to data cleaning to prepare a dataset for that in Matlab. I'm using the inflation dataset attached from the World Bank.
In short, I am trying to drop all rows that are completely null, because I need to be able to impute those NaNs, and eventually be able to attach my predictions to the same rows in the original dataset.
My process so far is to read the csv in as a table. drop all the text columns except for the country, reserve the orignal dataset for joining it back later, then normalize the data between 0 an 1 and then impute the nulls.
I've tried the following, but, I keep getting Incorrect number or types of inputs or outputs for function 'isnan'. error, and I'm not sure what I'm doing wrong.
N = table2cell(N);
N(cellfun(@(cell) any(isnan(cell(:))),N))={''};
empties = cellfun('isempty',N);
N(empties) = {NaN};
N(all(isnan(N),2),:) = \[\];
indices = find(N(:,2)==0);
N(indices,:) = \[\];
Original code, minus the removing rows that are NaNs
N = readtable('inflation.csv','NumHeaderLines',5);
N(:,\[2,3,4\]) = \[\];
n = N;
n(:,1) = \[\];
n = normalize(n, 'range');
n = knnimpute(n);
Accepted Answer
C = readcell('Inflation.csv')
N\_header\_lines = 3;
rows\_to\_delete = N\_header\_lines + find(all(cellfun(@ismissing,C(N\_header\_lines+1:end,5:end)),2));
C(rows\_to\_delete,:) = \[\]
## More Answers (2)
For tables, there is a very handy [rmmissing](https://www.mathworks.com/help/matlab/ref/rmmissing.html) function:
T = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded\_files/1241637/Inflation.csv",'NumHeaderLines',5);
size(T)
ans =
266 66
R = rmmissing(T);
size(R)
ans =
66 66
Try this:
filename = 'Inflation.csv'
data = readmatrix(filename)
rowsToDelete = all(isnan(data), 2)
data(rowsToDelete, :) = \[\]
### Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you\!
[Start Hunting\!](https://www.mathworks.com/matlabcentral/community/onramps/mlc_treasure_hunt?s_tid=hunt_spotlight) | |||||||||
| ML Classification | ||||||||||
| ML Categories |
Raw JSON{
"/Computers_and_Electronics": 976,
"/Computers_and_Electronics/Software": 650,
"/Computers_and_Electronics/Software/Software_Utilities": 252
} | |||||||||
| ML Page Types |
Raw JSON{
"/Article": 685,
"/Article/How_to": 318
} | |||||||||
| ML Intent Types |
Raw JSON{
"Informational": 923
} | |||||||||
| Content Metadata | ||||||||||
| Language | en | |||||||||
| Author | null | |||||||||
| Publish Time | not set | |||||||||
| Original Publish Time | 2022-12-27 19:35:36 (3 years ago) | |||||||||
| Republished | No | |||||||||
| Word Count (Total) | 5,864 | |||||||||
| Word Count (Content) | 288 | |||||||||
| Links | ||||||||||
| External Links | 1 | |||||||||
| Internal Links | 133 | |||||||||
| Technical SEO | ||||||||||
| Meta Nofollow | No | |||||||||
| Meta Noarchive | No | |||||||||
| JS Rendered | No | |||||||||
| Redirect Target | null | |||||||||
| Performance | ||||||||||
| Download Time (ms) | 1,066 | |||||||||
| TTFB (ms) | 1,061 | |||||||||
| Download Size (bytes) | 39,197 | |||||||||
| Shard | 161 (laksa) | |||||||||
| Root Hash | 11303084394109755361 | |||||||||
| Unparsed URL | com,mathworks!www,/matlabcentral/answers/1883812-remove-rows-that-are-entirely-nan s443 | |||||||||