MATLAB How Can I Load and Format Dates in MATLAB from an Excel or Text File?

  • Thread starter Thread starter carlosvelcab
  • Start date Start date
  • Tags Tags
    Load Matlab
Click For Summary
The discussion focuses on a common issue in MATLAB regarding the conversion of date strings from an Excel or text file into a date format that MATLAB can recognize. The user has a list of dates formatted as 'YYYY MM DD' and seeks to display them in a more readable format, such as 'DD-MMM-YYYY'. The solution involves using the `datenum` function to convert the string to a date-type variable, followed by the `datestr` function to format the date. An example provided illustrates the combined use of these functions to achieve the desired output.
carlosvelcab
Messages
4
Reaction score
0
hi every one, I have a problem for load dates in matlab, I have 2488 dates
in xls file and txt file but I can't make that MATLAB read the number as a dates? Does anybody know how to do it?
for example I have this:
2000 03 01
2000 04 01
2000 05 01
2000 06 01
.
.
.

And I want that MATLAB shows me

03-Jan-2000
04-Jan-2000
05-Jan-2000

please help me
 
Physics news on Phys.org
++ Firstly, you need to convert string to date-type variable by using datenum.
Ex: datenum('2000 03 01', 'yyyy dd mm')

++ Secondly, using datestr:
Ex: datestr(time, 'mmmm dd, yyyy')

Combining: datestr(datenum('2000 03 01', 'yyyy dd mm'), 'mmmm dd, yyyy')

Hope this helps
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
9K
  • · Replies 7 ·
Replies
7
Views
8K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
5K