Remove unwanted text/punctuation from table
9 ビュー (過去 30 日間)
古いコメントを表示
There is probably a simple way to do this but for whatever reason, I seem to be struggling a little. I have a table that is nxn in size. One column in this table has cells that contain text within quotation marks along with cells that simply have quotation marks. I'm trying to extract the rows that have cells from that column containing text within the quotation marks. In essence, I want to remove rows that have only quotes. For example, my table looks like this:
1 2 3 ""
4 5 6 ""
7 8 9 "yes"
10 11 12 "no"
13 14 15 "ok"
In the example above, what I want is to find the indices of the rows that contain cells with words in the last column- I want to filter out the rows that simply have ' "" ' in the last column as shown. I've tried the 'find' and 'contains' commands but trying to specify ' "" ' as the object to find selects every row since even the words in the last column in the example above are within quotes. Can someone please offer some advice? For reference, I'm using MATLAB R2019b. Thanks!
0 件のコメント
採用された回答
Cris LaPierre
2021 年 6 月 28 日
編集済み: Cris LaPierre
2021 年 6 月 28 日
Standardize your missing values to MATLAB default values, then use rmmissing to remove any row that contains a missing value.
% Create your table
var1 = [1 4 7 10 13]';
var2 = [3 5 8 11 14]';
var3 = ["" "" "yes" "no" "ok"]';
T = table(var1,var2,var3)
% Standardize missing values
T.var3 = standardizeMissing(T.var3,"")
% remove any row with a missing value
Tnew = rmmissing(T,1)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!