How to remove rows in table that have empty values

I have the following tables with two columns
Look at the second last and third last rows, see how the right column has values []
I want to remove all rows within the table that have that value []
My main objectives is to sort the table by the right column, however, i cannot because it errors "Some cells in X contain non-scalar values and cannot be sorted."
So i'm thinking if i can remove all rows of data that have the values [], then i can sort it.
Please inform how I can do this
'A' 52201554
'B' 2130725
'C' 138307808
'AAC' 1220000
'AAC.U' []
'AAC.WS' []
'AAIC' 121888

1 件のコメント

Image Analyst
Image Analyst 2021 年 9 月 23 日
Attach a sample table with empty row(s) in a .mat file with the paperclip icon.

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

回答 (1 件)

KSSV
KSSV 2021 年 9 月 23 日

0 投票

Let T be your table.
idx = ismepty(T.(2)) ;
T(idx,:) = [] ;

2 件のコメント

Rizwan Khan
Rizwan Khan 2021 年 9 月 23 日
Dear Sir,
I tried your suggestion, however, isempty(T.(2)) just returns a single value not an series of values.
so the value return in idx is just 0, not the list of index values that are empty
Rizwan Khan
Rizwan Khan 2021 年 9 月 23 日
Dear Sir,
Your code did give me an idea.
when i do isempty(cell2mat(T.(2)(5)) i get true
so if i check the data in row 5 column 2 in the table above, by first converting from cell2mat, i get true
But the problem now is, how can i run that across the complete table without using a for loop.
So when i do the code below i get an error "All contents of the input cell array must be of the same data type."
isempty(cell2mat(T.(2)))

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

カテゴリ

ヘルプ センター および File ExchangeTables についてさらに検索

製品

リリース

R2020b

質問済み:

2021 年 9 月 23 日

コメント済み:

2021 年 9 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by