How to add a column with all rows have the same data in a table?

 Respuesta aceptada

Demo
% Create table
T = table([1;2;3;4],'VariableNames',{'Data'});
% Create date vector
data = datetime('now') + (1:4)';
% Add the column of dates to the table
T.Dates = data;
The column vector must have the same number of rows as the table.

4 comentarios

Mario Diaco
Mario Diaco el 26 de Mayo de 2020
Editada: Mario Diaco el 26 de Mayo de 2020
Sorry, but to set the same date in all rows?
data = repmat(datetime('now'), height(T), 1)
The line above will replicate the datetime value to the height of the table T.
Replace the first input to repmat with your datetime value and replace T with your table name.
Thanks a lot!
Adam Danz
Adam Danz el 26 de Mayo de 2020
Editada: Adam Danz el 3 de Nov. de 2020
Glad I could help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Productos

Versión

R2020a

Etiquetas

Preguntada:

el 26 de Mayo de 2020

Editada:

el 3 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by