![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/192017/image.jpeg)
convert date to datenum import from excel
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
hello
I want to import a simple excel file to matlab and convert the column with dates from text to numeric values. The problem is that the rule convert does not show up as an alternativ. I can only replace things. Would be very glad if someone could help.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/192040/image.jpeg)
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 17 Jul. 2018
Bearbeitet: Adam Danz
am 17 Jul. 2018
I agree that readtable() is the better option but if you decide to stick with the import tool, here's an idea.
In the dropdown menu under your variable name 'dag' where it currently says "Number" in your screenshot, select a date and time option. This will convert your timestamps to datetime format. After importing, you can use datenum() to convert them to double if desired.
Here's a screen shot with a different data set.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/192017/image.jpeg)
3 Kommentare
Adam Danz
am 17 Jul. 2018
Yeah, that might be the problem. After you select datetime you'll need to re-generate the importfile() function so the new version accounts for the new format.
Weitere Antworten (2)
Walter Roberson
am 17 Jul. 2018
We recommend using readtable() instead. With new enough MATLAB, it can help to use detectImportOptions() with readtable()
0 Kommentare
ErikJ
am 19 Jul. 2018
4 Kommentare
Adam Danz
am 19 Jul. 2018
Bearbeitet: Adam Danz
am 19 Jul. 2018
doc xlswrite()
Read about the inputs and how to use this function. There's even an example that shows you how to insert data into specific cells of the spreadsheet. I was about to type up a quick demo but Matlab's documentation covers it. The best way to learn is by digging into the documentation. If you get stuck, come back.
It would be wise to make a copy of your data as you poke around with this function in case you accidentally overwrite your data.
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!