Problems while exporting the data to excel file from MATLAB.
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I would like to ask you a help to solve an issue while exporting time data from matlab to excel file. The code I use is shown below
if true
% code
end
filename = 'C:\.....\myFile4.xlsx';
sheet = 1;
a = 1;
while a<20
d{a,1} = datestr(now,'HH:MM:SS');
d{a,2} = rand(1);
d{a,3} = rand(1);
d{a,4} = rand(1);
d{a,5} = 'String';
A ={d{a,1},d{a,2},d{a,3},d{a,4},d{a,5}};
xlRange = strcat('C',num2str(a)); % Set the cell location
xlswrite(filename,A,sheet,xlRange)
a = a+1;
end
The data is getting written in the excel file but the time values in the first coloum seems to be some fractional numbers. How can I get the time values written in the format 'HH:MM:SS' in the excel file?
0 commentaires
Réponses (1)
Tushar Agarwal
le 31 Mar 2017
Hello - the conversion is probably due to the fact that excel has a different starting timestamp in its history, and Matlab I think starts in 01-01-1900. These numbers represnt the number of seconds since the start of this particular date (as mentioned above). What you could do, is select the time stamp column on excel, and format it there - using the format option -> time -> and choose your preferred format.
Else - go ahead and export it as a table instead of an xlsx. It will still be an xlsx, but the timestamp doesnt get varied. check TABLE .
0 commentaires
Voir également
Catégories
En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!