plot date from excel file
Afficher commentaires plus anciens
hi all, I am trying to plot power vs time in my program, these values are taking from excel file, but I am having different values for the time compare with values in excel, the time format is (HH:MM)and my code is:
[num,T,vT] = xlsread(excle.xls,'Sheet1'); % reading excel
x = num(:,1); % Time column
y = num(:,4); % power column
plot(handles.axes,x,y);
how can I over come this issue ??? please help and advice...
3 commentaires
Conrad
le 26 Juil 2012
Can you give a concrete example of what the time looks like in Excel and then in Matlab?
Sumit Tandon
le 26 Juil 2012
Not sure if I understand the question correctly. Are you having issues with the FORMAT of date in Excel vs MATLAB? You could use functions like DATENUM or DATEVEC to change the format and then plot as per your requirements.
Samer Husam
le 26 Juil 2012
Réponses (2)
Thomas
le 26 Juil 2012
Something like this
x={'12:00','12:15','12:30','12:45'}; %time
y=[0.5 0.8 0.3 0.6] % values
time_out=datenum(x,'HH:MM'); %convert time to datenum
plot(time_out,y)
datetick('x','HH:MM') % show datetick on xaxis
5 commentaires
Samer Husam
le 26 Juil 2012
Thomas
le 26 Juil 2012
what error are you getting and can you show how x is in MATLAB?
Samer Husam
le 26 Juil 2012
Thomas
le 26 Juil 2012
so what is your 'x'? Can you show an example of 'x' as it is imported in matlab. also what is the output of
whos x
Samer Husam
le 26 Juil 2012
Modifié(e) : Samer Husam
le 26 Juil 2012
Samer Husam
le 28 Juil 2012
0 votes
Catégories
En savoir plus sur Data Import from MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!