How to concentrate time variables in separated columns for time series plot?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I'm new to Matlab, and I'm now working on a time series plot using a file whose hh:mm:ss are in 3 different columns.
How do I do to combine them to a single column? Or is it necessary to do so?
It would also be nice if there are some other ways that could show the time on x-axis.
0 comentarios
Respuestas (1)
Abhishek Singh
el 10 de Feb. de 2019
Let’s break it down the problem into 2 parts:
1). Loading the data from file
Assuming the table is in this format, named as ‘time_file.txt’.
You can load it into a matrix using:
timeseries_data = importdata('time_file.txt',',') % here ‘,’ being the delimiter
2). Converting it into datetime array
timearray = datetime(timeseries_data) %this is the datetime array that is being required
Remember that the datetime function takes arguments as (year, month, date).
If your matrix has columns in form (date, month, year), then overcome this using:
flipped_matrix = fliplr(timeseries_data) % this flips the matrix from left column to right
Now use timearray in plot function as x-axis.
0 comentarios
Ver también
Categorías
Más información sobre Dates and Time 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!