Make Variable Names in a table numbers
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Abinand Rejimon
am 22 Jun. 2022
Kommentiert: Abinand Rejimon
am 22 Jun. 2022
I have a table that needs to have the variable names (columns) as numbers. When I try to assign the variablenames to the table t, i get this error. It is an array of 800 numbers that each have to be assigned a column. How do I make this work? Is there a way I can use array2table and specify the first row of numbers as the header? That is what I am trying to do below but it is not working.
t = array2table(allDataT(2:26,:)) %converting allDataT from rows 2 to 26 to a talbe
t.Properties.VariableNames = (allData(1,:)) % Trying to specify that the first row of numbers should be the header
% ERROR: The VariableNames property is a cell array of character vectors.
% To assign multiple variable names, specify nonempty names in a string arrayor a cell array of character vectors.
0 Kommentare
Akzeptierte Antwort
Jan
am 22 Jun. 2022
Header are strings, not numbers. You cannot use numbers to be a header.
allData = reshape(1:64, 8, 8)
t = array2table(allData);
t.Properties.VariableNames = string(allData(1,:))
Instead of 1,9, ... you have the headers "1", "9", ...
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!