フィルターのクリア

trouble with plotting dates on x-axis

1 回表示 (過去 30 日間)
Noah Poole
Noah Poole 2018 年 8 月 25 日
コメント済み: Walter Roberson 2018 年 8 月 25 日
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

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 8 月 25 日
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);
  2 件のコメント
Noah Poole
Noah Poole 2018 年 8 月 25 日
編集済み: Walter Roberson 2018 年 8 月 25 日
Hi,
when I use this now I get:
date2016 = Brisbane2016{:,1};
pollution2016 = Brisbane2016{:,2};
plot(date2016,pollution2016)
which returns:
Error using plot
Not enough input arguments.
Walter Roberson
Walter Roberson 2018 年 8 月 25 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by