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

2 次查看(过去 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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by