フィルターのクリア

where can i find a complete list of table variable types?

57 ビュー (過去 30 日間)
STEVEN SATTERFIELD
STEVEN SATTERFIELD 2022 年 9 月 22 日
編集済み: Eric Sofen 2022 年 9 月 23 日
where can i find a complete list of table variable types?

回答 (1 件)

Chunru
Chunru 2022 年 9 月 22 日
% Create table
LastName = ["Sanchez";"Johnson";"Zhang";"Diaz";"Brown"];
Age = [38;43;38;40;49];
Smoker = [true;false;true;false;true];
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80];
patients = table(LastName,Age,Smoker,Height,Weight,BloodPressure)
patients = 5×6 table
LastName Age Smoker Height Weight BloodPressure _________ ___ ______ ______ ______ _____________ "Sanchez" 38 true 71 176 124 93 "Johnson" 43 false 69 163 109 77 "Zhang" 38 true 64 131 125 83 "Diaz" 40 false 67 133 117 75 "Brown" 49 true 64 119 122 80
cellfun(@ (x) fprintf('%s: %s\n', x, class(patients.(x))), patients.Properties.VariableNames)
LastName: string Age: double Smoker: logical Height: double Weight: double BloodPressure: double
  1 件のコメント
Eric Sofen
Eric Sofen 2022 年 9 月 23 日
編集済み: Eric Sofen 2022 年 9 月 23 日
Interpreting the question in the same way as Chunru, you can also do summary(patients) or varfun(@class, patients) to get the classes of each variable in a table.
If you're asking what types are allowed as table variables, it's essentially anything in MATLAB that behaves like an array. That is, scalar-only types cannot be table variables (but they can be put in a cell array and that cell array can be a table variable). The table doc specifies, "Common input variables are numeric arrays, logical arrays, character arrays, structure arrays, or cell arrays. Input variables also can be objects that are arrays. Such an array must support indexing of the form var(index1,...,indexN), where index1 is a numeric or logical vector that corresponds to rows of the variable var. In addition, the array must implement both a vertcat method and a size method with a dim argument."

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeTables についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by