# Can't get all the rows in my table that have any missing values and remove those rows

4 ビュー (過去 30 日間)
Dhruv Ghulati 2015 年 12 月 18 日

Hi there,
I am trying to remove my table (of a combination of double, cell arrays and duration arrays) of any rows which have missing values. For example, a subset of the table is:
'' '' '441' '0'
'' '' '5' '0'
'No' '' '2889' '0'
'No' 'Clicks' '2894' '0'
'' '' '' '0'
'' '' '5' '0'
'No' 'ROD' '3591' '1'
'' '' '' '0'
My code is:
However, this results in an error:
Row index exceeds table dimensions.
What am I doing wrong, and what code do I need to achieve my need?
##### 4 件のコメント表示非表示 3 件の古いコメント
Dhruv Ghulati 2015 年 12 月 18 日
Apologies, you are right, here the question in the title doesn't match the question in the body given. For the sake of other readers I am amending the title.

サインインしてコメントする。

### 採用された回答

the cyclist 2015 年 12 月 18 日
This should solve it for you:
A = {
'' '' '441' '0';
'' '' '5' '0';
'No' '' '2889' '0';
'No' 'Clicks' '2894' '0';
'' '' '' '0';
'' '' '5' '0';
'No' 'ROD' '3591' '1';
'' '' '' '0'};
T = cell2table(A)

サインインしてコメントする。

### その他の回答 (1 件)

Guillaume 2015 年 12 月 18 日

badRows is an m*n logical array, where m is the number of rows and n the number of columns of your table. So it has m*n elements. You're then using that as a row index into your table, so of course, matlab can't fit m*n values into m values.
To fix this, use the any (or all) function:
%or
P.S.: this answer your question on how to remove any row which has missing value. If you want to remove rows have more than x missing values, then you use sum instead:
T = finalnbs(sum(badrows, 2) <= x, :);

サインインしてコメントする。

### カテゴリ

Find more on Tables 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!

Translated by