필터 지우기
필터 지우기

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 CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by