Info
此问题已关闭。 请重新打开它进行编辑或回答。
Plot from 2 matrixes as x value and 1 matrix as y
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
David Hill
2020-9-21
Should not be difficult. Please provide a sample of what your data looks like. What have you done so far?
回答(1 个)
Seth Furman
2020-10-21
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 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!