too many input argument while plotting date and time

조회 수: 4 (최근 30일)
chanz agrawa
chanz agrawa 2019년 4월 20일
답변: Cris LaPierre 2019년 4월 20일
i want to plot this on matlab. the code i am trying is
[~,~,v]=xlsread('solarg55.xlsx')
v=v(2:end,:);
x=datenum(v(:,1),'dd/mm/yyyy HH:MM:SS')
y=cell2mat(v(:,2))
[idx,idx]=sortrows([x,y])
plot(x(idx),y(idx))
xticks=get(gca,'Xtick')
set(gca,'xticklabel',datestr(xticks,'dd/mm/yyyy HH:MM:SS'))
but it gives me this error
Error using date
Too many input arguments.
  댓글 수: 2
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 4월 20일
편집: KALYAN ACHARJYA 2019년 4월 20일
Pls Attach solarg55.xlsx
chanz agrawa
chanz agrawa 2019년 4월 20일
edited

댓글을 달려면 로그인하십시오.

답변 (1개)

Cris LaPierre
Cris LaPierre 2019년 4월 20일
Not sure exactly what your desired outcome is. However, why not use readtable, which loads your data into a table? It can handle your dates automatically as datetimes. When you plot with a datetime, the axis labels are dates. No need to set the label manually. You can also sort a table.
Try this code:
opts = detectImportOptions('solarg55.xlsx');
data = readtable('solarg55.xlsx',opts);
data.Properties.VariableNames = {'X','Y'};
data = sortrows(data,{'X','Y'});
plot(data.X,data.Y)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by