for minimization process Boolean function by using binary decision diagram.

 채택된 답변

Walter Roberson
Walter Roberson 2026년 3월 30일
편집: MathWorks Support Team 2024년 11월 13일

19 개 추천

table2array() . Or, if the table is all numeric, you can give the table name and then {:, :} such as mytable{:,:}

댓글 수: 2

satya deep
satya deep 2018년 2월 7일
I want the table to matrix sir.
Walter Roberson
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개)

FAS
FAS 2018년 11월 20일

17 개 추천

Suppose your table is X.
X = X{:,:}

댓글 수: 3

JoshT_student
JoshT_student 2022년 12월 2일
Best answer.
Walter Roberson
Walter Roberson 2022년 12월 2일
Same as the second solution that I had posted 8 months earlier...
Jacob Conrad
Jacob Conrad 2023년 3월 15일
dont be a jerk walter

댓글을 달려면 로그인하십시오.

MathWorks Support Team
MathWorks Support Team 2020년 9월 2일
편집: MathWorks Support Team 2020년 9월 2일

1 개 추천

To convert a table to a matrix, use the table2array function. (A matrix is a 2-D array.)
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
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
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
Sulaymon Eshkabilov 2021년 8월 4일

1 개 추천

Another alternative to convert table to matrix is to use a syntax: M=T.Var, e.g.
T = table(magic(5))
T = 5×1 table
Var1 __________________________ 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
M=T.Var1
M = 5×5
17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9

댓글 수: 6

Walter Roberson
Walter Roberson 2021년 8월 4일
This depends upon there being only a single variable in the table. That is possible, but not the most common arrangement.
Yes, it works for multiple variables as well, but it becomes painstakingly heavy for such cases, e.g.:
T = array2table(magic(5), 'VariableNames', {'Var1','Var2','Var3','Var4','Var5'})
T = 5×5 table
Var1 Var2 Var3 Var4 Var5 ____ ____ ____ ____ ____ 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
M = [T.Var1, T.Var2, T.Var3, T.Var4, T.Var5]
M = 5×5
17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9
Walter Roberson
Walter Roberson 2021년 8월 4일
At that point, table2array() or using {:,:} indexing becomes a lot more convenient.
Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 8월 4일
Yes, indeed.
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
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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by