Identify and delete a specific column?
11 次查看(过去 30 天)
显示 更早的评论
Hi guys!
I need to delete 1 specific column, which may be in different positions (e.g. it can be the 1st, 2nd or 3rd column) depending on the file in use. The specific column to delete is the one where in the 1st row indicates 'O' (O for the element Oxygen). This might be simple, but I'm at beginner level. Any help would be very much appreciated!
2 个评论
Massimo Zanetti
2016-9-29
Column of what? What is your data, matrix, cell, array? Put examples in your explanation otherwise no one can understand your problem.
This will help you to get an answer.
采纳的回答
Guillaume
2016-9-29
编辑:Guillaume
2016-9-29
YourCellArray(strcmp(YourCellArray(1, :), 'O'), :) = []
will delete all columns for which the first row is 'O'.
With regards to the data structure, it's fine to have it as you have as a cell array, but maybe better would be to have a table with just numbers and name the columns after the elements:
composition = cell2table(YourCellArray(2:end, :), 'VariableNames', YourCellArray(1, :));
To remove the 'O' column is then trivial:
composition.O = [];
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genomics and Next Generation Sequencing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!