I'd like to remove variables (columns) containing specifc name
16 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have a kind of big data table (eg. 300 variables) and I'd like to sort out the table by removing variables.
I imported csv file and it has variable names showing the pattern such as xxxx_A or yyyy_B
So I tried to use removevars function to remove all columns containing '_B' but failed
Actually I am not sure how to determine specific variables
I'd appreciate if anyone can help to sort out the table by specific column name
Thanks
0 Kommentare
Antworten (2)
Image Analyst
am 17 Mai 2023
Try this:
% Create sample table.
rows = 5;
xxxx_A = 1:rows;
yyyy_B = rand(rows, 1);
col3 = rand(rows, 1);
t = table(xxxx_A(:), yyyy_B(:), col3, 'VariableNames', {'xxxx_A', 'yyyy_B', 'col3'})
% Now remove the column called "yyyy_B"
t = removevars(t, 'yyyy_B')
0 Kommentare
Siehe auch
Kategorien
Mehr zu Tables 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!