trouble with plotting dates on x-axis
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm using the following code:
%Question 2
%First load data into script
date= brisbanecbdaq2010(:,1)
pollution= brisbanecbdaq2010(:,2)
plot(date,pollution)
when I run this it gives the following:
Error using tabular/plot
Too many input arguments.
The data I'm using is simply a column of dates in the form dd/mm/yyyy and the second column is just numeric values.
can someone please help.
Thanks
0 Commenti
Risposte (1)
Walter Roberson
il 25 Ago 2018
You get that error message when you attempt to plot using a table() object with more than one parameter. If you were to reduce down to, for example, plot(date) where date is a table object, then you would get a more clear error message such as,
Error using tabular/plot (line 156)
There is no plot method for the 'table' class. Plot the variables in a table using dot or brace subscripting.
The problem you have is that you used () indexing to extract a column from a table() object, instead of using {} indexing:
date = YourTable{:,3};
pollution = YourTable{:,8};
whereas you would have had something like
date = YourTable(:,3);
pollution = YourTable(:,8);
I showed you the {} syntax in https://www.mathworks.com/matlabcentral/answers/415891-how-to-plot-date-and-time-data-on-the-same-axis?s_tid=prof_contriblnk#answer_333789 which you have not replied to.
2 Commenti
Walter Roberson
il 25 Ago 2018
If you are using the same file format as before, then column 2 is not pollution levels, and is instead time of day. readtable is not automatically detecting that it is time of day and is instead importing it as a cell array of character vectors. When you then try to use that cell array of character vectors as an argument to plot(), plot cannot parse the input correctly as it tries to interpret the character vectors as options.
In your other question I showed retrieving column 3 and column 8. Column 3 is datetime and column 8 is ppm10 numeric readings.
Vedere anche
Categorie
Scopri di più su Dates and Time 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!