how to read excel data in matlab?

2 visualizzazioni (ultimi 30 giorni)
SONI SONI
SONI SONI il 15 Mar 2016
Risposto: Walter Roberson il 15 Apr 2016
I have daily time series data for 10 year in excel sheet (365 values in every year). Now I want to monthly sum this daily data and create a monthly time series (12 values of every year). How to import this excel sheet in matlab? I imported the excel sheet in matlab using import tool but, matlab is not reading format of date.
Example: Date data
01-01-2000 45
02-01-2000 25
03-01-2000 88..............
31-01-2000 56
01-02-2000 69
02-02-2000 28
03-02-2000 63..............
28-02-2000 91
  3 Commenti
Explorer
Explorer il 15 Mar 2016
Modificato: Explorer il 15 Mar 2016
Upload your excel file and your code file to let others help you in a better way.
Helen Kirby
Helen Kirby il 15 Apr 2016
This is what I did: Change your DD-MM-YYYY format in your Excel file to MM/DD/YYYY or MM/DD/YY. When it is in this form you can add the constant 695422 to change it from the XL date number to the ML date number. Say your XL date is in J4, you use (J4)+695422. You should keep the XL date around because it is a nuisance to keep having to work out the date from 736085 e.g. After you have a column of ML dates, read in the file as Explorer says above then start picking out your months as you require. You may need "Datevec" for that process.

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 15 Apr 2016
If you are using R2014b or later, use readtable() and the times will be converted to datetime objects.
If you are using R2013b or R2014a then readtable() still exists but there will be no automatic conversion of the times to time objects.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by