如何创建主表中的许多表并将其存储? [英] How can I create many tables of the main one and store them?
本文介绍了如何创建主表中的许多表并将其存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
my_table = readtable('some.csv')
'L1' 'B'
'L2' 'B'
'L3' 'A'
'L4' 'C'
'L5' 'B'
'L6' 'C'
'L7' 'C'
'L8' 'A'
在第二列中,有不同的值B,A和C.我想根据该值创建较小的表,具体取决于右侧的值,因此预期结果将是:
In the second column there are different values, B, A, and C. I want to create smaller tables from this one, depending on the value in the right, so the expected outcome would be:
'L1' 'B'
'L2' 'B'
'L5' 'B'
和
'L3' 'A'
'L8' 'A'
和
'L4' 'C'
'L6' 'C'
'L7' 'C'
它们中的每一个都存储在不同的变量中以供以后使用.
each of them stored in a different variable for later use.
推荐答案
您可以使用my_table.Variables
或my_table.my_column_header
访问表内容.从那里,您可以将值与A
,B
和C
进行比较;然后创建新表.
You can access table contents with my_table.Variables
or my_table.my_column_header
. From there, you can compare the values with A
, B
and C
; then create new tables.
% Get the ABC column.
content=my_table.Variables;
ABC = char(content{:,2});
% Alternatively, if you have the header.
ABC = char(my_table.Line2);
% Create new tables.
tableA = table(my_table(ABC == 'A',:));
tableB = table(my_table(ABC == 'B',:));
tableC = table(my_table(ABC == 'C',:));
这篇关于如何创建主表中的许多表并将其存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文