How do I define an empty table of unknown size?
이전 댓글 표시
Hi,
I want to define an empty table to fill in a for loop. The size of the table is defined by another variable. How do I define the "VariableType" variable without knowing how many variables there are? In my case they will all be strings. Example:
T = table('Size', [2, numel(Elements)], 'VariableType',["string","string","string","string","string"]);
In this particular cae, numel(Elements) would be 5. But how do I define the table if I don't know numel(Elements) ?
채택된 답변
추가 답변 (1개)
Walter Roberson
2020년 5월 26일
0 개 추천
Sorry, variables that do not exist do not have any datatype.
As you add variables to the table, the datatype associated with the variable will be the determined by the datatype of the value being assigned. If necessary, string() the value you are assigning into the table.
댓글 수: 3
Fabrice Lambert
2020년 5월 26일
Walter Roberson
2020년 5월 26일
That is not an empty table with an unknown number of variables: that is a table with 2 rows and a known number of variables.
Fabrice Lambert
2020년 5월 26일
편집: Fabrice Lambert
2020년 5월 26일
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!