Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Plot from 2 matrixes as x value and 1 matrix as y
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Fredrik Preus Dovland
el 21 de Sept. de 2020
Cerrada: MATLAB Answer Bot
el 20 de Ag. de 2021
Ok, so I have 2 cell-arrays:
Time{} = 1x4249
The time format is: HH:MM
Date{} = 1x4249
The date format is: dd.mm.yyyy
They corresponds to each other and the lasts 7 days. In addition to those arrays I have another matrix for available parking spots thoughout 7 days:
parking[] = 1x4249
My task is to plot 180 values from parking for each Xtick which is eaqual to 6 hours from the time cell. On the labels of the plot I have to include both the date and time at the x-axis and the avalability at the y-axis.
I am pretty new to Matlab so i would really appreciate help, and if the description was a little confusing I apologize.
3 comentarios
David Hill
el 21 de Sept. de 2020
Should not be difficult. Please provide a sample of what your data looks like. What have you done so far?
Respuestas (1)
Seth Furman
el 21 de Oct. de 2020
1) It is simpler and more efficient to store durations and datetimes in a duration or datetime array respectively instead of a cell array.
Assuming Time is a cell array of durations and Date is a cell array of datetimes, we can convert them as follows.
Time = [Time{:}];
Date = [Date{:}];
2) As the name implies, datetime arrays can store date AND time information, so we can combine Date and Time.
Date = Date + Time;
Date.Format = 'dd.MM.yyyy hh:mm';
3) Datetimes can be plotted directly with our data.
Assuming parking is an array of doubles, we can plot them as follows.
plot(Date,parking)
Please refer to the following page in the documentation for more information.
4) Capitalization matters when setting the format of a datetime or duration.
The format "dd.mm.yyyy" refers to days, minutes, and years. In fact we probably want "dd.MM.yyyy", which refers to days, months, and years.
Please refer to the documentation for datetime for more information.
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!