Borrar filtros
Borrar filtros

Convert table to array and back to table

12 visualizaciones (últimos 30 días)
Krishna
Krishna el 21 de Jun. de 2022
Comentada: Krishna el 21 de Jun. de 2022
Hi, I want to convert my table 'T'(1000 X 70) to an array 'A'. The table 'T' contains 70 different column headers. I again want to convert the array 'A' back to table 'T' without losing the column headers. How is it possible to do without manually entering all the 70 column headers as given below:
T = array2table(A,...
'VariableNames',{'Feet','Inches','Centimeters'})

Respuesta aceptada

Kevin Holly
Kevin Holly el 21 de Jun. de 2022
A = randi([1 10],5,3)
A = 5×3
9 7 4 4 8 6 1 9 4 1 8 7 4 4 5
T = array2table(A,'VariableNames',{'Feet','Inches','Centimeters'})
T = 5×3 table
Feet Inches Centimeters ____ ______ ___________ 9 7 4 4 8 6 1 9 4 1 8 7 4 4 5
Header = T.Properties.VariableNames
Header = 1×3 cell array
{'Feet'} {'Inches'} {'Centimeters'}
Array = table2array(T)
Array = 5×3
9 7 4 4 8 6 1 9 4 1 8 7 4 4 5
NewTable = array2table(Array,'VariableNames',Header)
NewTable = 5×3 table
Feet Inches Centimeters ____ ______ ___________ 9 7 4 4 8 6 1 9 4 1 8 7 4 4 5

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by