Plot data to a certain date with array

1 vue (au cours des 30 derniers jours)
PureFleet
PureFleet le 29 Nov 2021
Commenté : Peter Perkins le 2 Déc 2021
Sorry I am new to coding! Apologies if this is a dumb question.
I a years worth of data and an array saying 1 when it is january and 0 when its not. I need to plot data only when its january, but im unsure how to work in the array into my plot.
Thanks!

Réponses (1)

Peter Perkins
Peter Perkins le 29 Nov 2021
Give this a try:
>> tt = timetable((1:365)','RowTimes',datetime(2021,1,1:365))
tt =
365×1 timetable
Time Var1
___________ ____
01-Jan-2021 1
02-Jan-2021 2
03-Jan-2021 3
[snip]
29-Dec-2021 363
30-Dec-2021 364
31-Dec-2021 365
>> jan = tt.Time.Month == 1;
>> plot(tt.Time(jan),tt.Var1(jan))
  3 commentaires
PureFleet
PureFleet le 29 Nov 2021
nvm did it by adding (plotindex) at the end of each data
Peter Perkins
Peter Perkins le 2 Déc 2021
IIUC, my "jan" variable was the same as your "plotindex".

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by