Error time series plot: cannot perform numeric operation which have non numerical data

7 visualizzazioni (ultimi 30 giorni)
Hello everybody!
I had a table object that I transformed to timeseries. When it comes to plot it, I get an error... How can I solve this issue?
Thank you very much!
prova4 = timeseries(mmean1416_pt); %1x1 table timeseries, in which time is categorical in the form Jan-2014
plot(prova4)
Error using timeseries/plot (line 47)
Cannot perform numeric operations on timeseries which have non-numeric data

Risposta accettata

Walter Roberson
Walter Roberson il 24 Giu 2021
When you use timeseries() on a table object, then timeseries() does not look inside the table at the variables. It creates times 0:(rows-1) (seconds) where rows is the number of rows in the table. And the data associated with the time is the entire table row.
But table rows are not numeric, they are table() objects. And table() objects cannot be plotted.
If you have a table object that has a time field, you should consider creating a timetable(). There is no plot() for timetable objects, but you can access the Time property and whatever variable is appropriate.
Caution: If your times are categorical, then you have to be careful in how you construct the categorical in order to impose a sorting order and associated position values. Probably easier to datetime() with a 'convertfrom' to convert the categorical text into datetimes.
  7 Commenti
CARLOTTA DENTICO
CARLOTTA DENTICO il 25 Giu 2021
an error again :(((
Error using timetable (line 470)
Row times must be datetime or duration vector.
Walter Roberson
Walter Roberson il 25 Giu 2021
What is the first entry in ts1416theta.Time ? Your comments earlier indicated it encodes 01-Jan-2014 00:30:00 but what is its class() and how does it show up when you display it?

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Time Series in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by