Effacer les filtres
Effacer les filtres


Cette question est clôturée. Rouvrir pour modifier ou répondre.

Plot from 2 matrixes as x value and 1 matrix as y

1 vue (au cours des 30 derniers jours)
Fredrik Preus Dovland
Fredrik Preus Dovland le 21 Sep 2020
Clôturé : MATLAB Answer Bot le 20 Août 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 commentaires
David Hill
David Hill le 21 Sep 2020
Should not be difficult. Please provide a sample of what your data looks like. What have you done so far?
Fredrik Preus Dovland
Fredrik Preus Dovland le 21 Sep 2020
So far i have:
Where "jernbanen_num" is the matrix containing available parking spots and "str" is a combined cell-array of the time and date

Réponses (1)

Seth Furman
Seth Furman le 21 Oct 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.
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.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by