add a vector as a timetable element
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
giacomo labbri
el 8 de Dic. de 2020
Comentada: giacomo labbri
el 9 de Dic. de 2020
Hi,
I would like to write the column of a matrix as element of a timetable (meaning a column for each time). in this timetable I have other variables that have a scalar value at each time. Any suggestion on how to do it?
Cheers,
Giacomo
0 comentarios
Respuesta aceptada
Cris LaPierre
el 8 de Dic. de 2020
Editada: Cris LaPierre
el 8 de Dic. de 2020
A column for each time? Do you mean row?
Just add it as a new variable in your timetable. Each column is typically a separate variable.
indoors = readtimetable('indoors.csv')
% Create temperatures
tempF = randi(100,[height(indoors),1]);
% Add vector of temperatures to timetable
indoors.Temp = tempF
3 comentarios
Cris LaPierre
el 9 de Dic. de 2020
Still not a problem. Can we assume the times in your timtable rows align with the times of your matrix colums?
Updating the example slightly.
% Creating a 60x2 timetable
indoors = readtimetable('indoors.csv');
% Creating a matrix with 4 heights x 60 times (reduced for visual purposes only)
tempF = randi(100,[4,60]);
% Add temps to timetable under a variable Temp
% Transopose tempF so that rows are times, and columns are heights
indoors.Temp = tempF'
indoors = splitvars(indoors,'Temp','NewVariableNames',["H1" "H2" "H3" "H4"])
Más respuestas (0)
Ver también
Categorías
Más información sobre Tables en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!