xlsread not extracting formatted content
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to use the xlsread function to extract a column of dates/times in a custom format. The original date format of the cell is "M/D/YY H:MM AM/PM". My custom format is "DD MMM YYYY HH:MM:SS.000" (because this is the format that STK/Matlab Object-model recognizes).
[~,dateTimeFixArray,~] = xlsread(filename,'D2:D1000')
When I use xlsread to import the data as a str I get an array in the original format instead of my custom format. Is there any way to force xlsread to extract my custom format instead?
0 commentaires
Réponses (1)
Star Strider
le 30 Juin 2015
The xlsread function uses Excel to read the contents of the file. If you want the dates and times in your custom format, first convert them to MATLAB date numbers with datenum, then convert them to your custom date strings with datestr.
2 commentaires
Star Strider
le 30 Juin 2015
My pleasure.
Not to my knowledge. The easiest way might be to use the Excel custom date format options and format the date column in every Excel file in the format you want. (You might be able to do that through MATLAB, but that could involve some significant ‘ActiveX’ programming that I’ve only read about in a few threads here. I’ve no experience with it.)
If I wanted to export the date in a particular format, I would do it in Excel and then not bother with the date string format conversions in MATLAB.
Voir également
Catégories
En savoir plus sur Spreadsheets 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!