hi.how to convert cell array to table?. i tried using cell2table() but it shows an error 'invalid function for the type cell'

3 ビュー (過去 30 日間)
if true
LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49];
Height =[71;69;64;67;64];
Age=cellstr(num2str(Age));
Height=cellstr(num2str(Height));
T = [{'','age','height'};[LastName,Age,Height]];
t=cell2table(T)
end

採用された回答

Jan
Jan 2017 年 12 月 13 日
編集済み: Jan 2017 年 12 月 13 日
LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49]; % No need to convert this to strings
Height = [71;69;64;67;64];
C = cat(1, LastName.', num2cell(Age.'), num2cell(Height.'));
T = cell2table(C, 'VariableNames', {'name', 'age', 'height'})
According to https://www.mathworks.com/help/matlab/ref/cell2table.html this should work. If you get a message like "invalid function for the type cell" (by the way: please post a copy of the complete message), you might work with a Matlab version older than R2013b, which did not have the table objects. Otherwise please look in your documentation about a working example:
doc cell2table
Try to run the examples. What do you observe? What is the difference to your code?
  3 件のコメント
Jan
Jan 2017 年 12 月 13 日
Sorry, R2013a did not have the cell2table command. table objects have been introduced in R2013b. I do not know, which "ExportToPPTX" function you mean, but I do not assume, that it requires modern table objects.
If you mean https://www.mathworks.com/matlabcentral/fileexchange/40277-exporttopptx, why do you think that you need a table object at all? The documentation contains an example, where a table is created directly from a cell array, see example.
Kimberly Andersen
Kimberly Andersen 2020 年 9 月 28 日
C comes out as a 3x5 cell array and needs to be a 5x3 array to form the table T

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by