too many input argument while plotting date and time
Mostrar comentarios más antiguos

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 comentarios
KALYAN ACHARJYA
el 20 de Abr. de 2019
Editada: KALYAN ACHARJYA
el 20 de Abr. de 2019
Pls Attach solarg55.xlsx
chanz agrawa
el 20 de Abr. de 2019
Respuestas (1)
Cris LaPierre
el 20 de Abr. de 2019
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)

Categorías
Más información sobre Dates and Time en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!