how to convert table to matrix?
2,997 次查看(过去 30 天)
显示 更早的评论
for minimization process Boolean function by using binary decision diagram.
0 个评论
采纳的回答
Walter Roberson
2024-11-13,0:00
编辑:MathWorks Support Team
2024-11-13,6:27
table2array() . Or, if the table is all numeric, you can give the table name and then {:, :} such as mytable{:,:}
2 个评论
Walter Roberson
2018-2-7
编辑:Walter Roberson
2018-2-7
The code I posted does that. Table objects are always 2 dimensional in MATLAB and for two dimensions the terms array and matrix are the same thing.
更多回答(4 个)
MathWorks Support Team
2020-9-2
编辑:MathWorks Support Team
2020-9-2
As an alternative, you can convert a table to an array by using the syntax “T{:,:}”, where “T” is the table. This syntax is the equivalent of “table2array”.
All variables in the table must have sizes and data types that allow them to be horizontally concatenated. For example, if all variables in “T” are numeric, then “table2array” returns a numeric array.
2 个评论
Arsalan Aftab Sayed
2020-12-16
I tried both table2array and “T{:,:}” but it changes the values inside the table from 0.7 to 1. Is there a way I can keep the original values, I tried using double datatype but it doesn't work
Walter Roberson
2020-12-16
table2array() converting 0.7 to 1 could happen if the table is mixed data type including at least one integer data type such as uint8 . Please check
unique( varfun(@class, T, 'outputformat', 'cell') )
Sulaymon Eshkabilov
2021-8-4
Another alternative to convert table to matrix is to use a syntax: M=T.Var, e.g.
T = table(magic(5))
M=T.Var1
6 个评论
David Alejandro Ramirez Cajigas
2021-8-18
What can I do if I have N var, with random names, inside a table that imports from excel, this table can vary.
that is, the method of putting T. "name var" is not possible if I have N quantity of varials with N different names
Walter Roberson
2021-8-18
You can use variable indexes if the indexes are constant.
If the variable order is not constant, then you can take T.Properties.VariableNames and extract whatever subset of those you want and sort them in whatever you want. Then you can loop doing dynamic field names.
Example, selecting variables that start with "run"
names = T.Properties.VariableNames;
runvars = sort(names(startsWith(names, 'run')));
nrun = length(runvars);
for varidx = 1 : nrun
thisvarname = runvars{varidx};
thiscontent = T.(thisvarname);
stuff here
end
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!