Problems while exporting the data to excel file from MATLAB.
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Tushar Agarwal
2017-3-31
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!