xlsread not extracting formatted content
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Star Strider
il 30 Giu 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 Commenti
Star Strider
il 30 Giu 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.
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!