Remove unwanted text/punctuation from table
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 28 Jun. 2021
Bearbeitet: Cris LaPierre
am 28 Jun. 2021
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)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!