Borrar filtros
Borrar filtros

importdata vs xlsread to read an excel file

16 visualizaciones (últimos 30 días)
Caroline
Caroline el 1 de Ag. de 2013
If I am reading an excel file, what is better to use in terms of time, importdata or xlsread? Is there something that is faster than both of these options?
Thanks!
  1 comentario
dpb
dpb el 1 de Ag. de 2013
A) Don't know; time it and see...I'd guess otomh xlsread may be a little better but that's purely a guess and probably makes a difference as to size and content as well...
B) Yeah, use something other than Excel as a data storage mechanism... :)

Iniciar sesión para comentar.

Respuesta aceptada

Evan
Evan el 1 de Ag. de 2013
Editada: Evan el 5 de Ag. de 2013
If you want to find out, try timing the operation of each function:
tic; xlsread('my_file.xlsx'); toc
tic; importdata('my_file.xlsx'); toc
I found that xlsread read in an excel file of 168 rows by 38 columns in 0.687730 seconds, while importdata took 3.690959 seconds.
If you want to read in your data more quickly, you could use a different file format, such as a txt or csv file. I attempted to read in the same data both saved as .xlsx and .csv, and this was my time difference:
>> tic;csvread('pretoria_2-1.csv');toc
Elapsed time is 0.001967 seconds.
>> tic;xlsread('pretoria_2-1.xlsx');toc
Elapsed time is 0.630418 seconds.
So it looks like, for my purposes, csvread is the preferable option. But it all depends on the format in which your data already exists and the trouble you'd have to go to in order to convert it.
  2 comentarios
Caroline
Caroline el 2 de Ag. de 2013
Thank you so much!
Evan
Evan el 5 de Ag. de 2013
No problem! :)

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by