Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

How to import Excel file to MATLAB

Asked by Lokman Abdullah on 2 Feb 2011
Latest activity Commented on by Image Analyst on 3 Nov 2013
         0	2.49939
  2.00E-04	-1.28174
  4.00E-04	3.05481
  6.00E-04	0.790405
  8.00E-04	-0.448608
  1.00E-03	2.28577
  1.20E-03	1.11084
  1.40E-03	8.54E-02
  1.60E-03	2.30713
  1.80E-03	1.77307
  2.00E-03	-0.83313
  2.20E-03	3.22571
  2.40E-03	1.34583
  2.60E-03	0.27771
  2.80E-03	1.19629
  3.00E-03	0.341797
  3.20E-03	1.36719
  3.40E-03	1.96533
  3.60E-03	0.448608
  3.80E-03	3.26843
  4.00E-03	0.683594
  4.20E-03	-1.83716
  4.40E-03	4.14429

For example, I have this kind of numerical data with 2 column and 10 rows in my excel file. How to import the Excel file to MATLAB? I need the data to plot the graph.

0 Comments

Lokman Abdullah

Products

No products are associated with this question.

2 Answers

Answer by Martijn on 2 Feb 2011
Accepted answer

Importing data from Excel can be done using the XLSREAD function, for example to read all data from myfile.xls:

A = xlsread('myfile.xls')

Or to only read a specific range from a specific sheet:

B = xlsread('myfile.xls','Sheet 1','B10:F28')

More information can be found in the documentation:

http://www.mathworks.com/help/releases/R2010b/techdoc/ref/xlsread.html

2 Comments

abdulkader helwan on 3 Nov 2013

i am trying this function but i get that error: XLSREAD unable to open file abd.xls. File C:\Users\Abdulkader\Documents\MATLAB\abd.xls not found. plz help

Image Analyst on 3 Nov 2013

The file is not there. Correct the filename, or else find the file and put it in that folder.

Martijn
Answer by Davide Ferraro on 2 Feb 2011

If you prefer to use an interactive approach you can double click on the Excel file from the Current Folder browser and interactively import the data. As soon as the data is in your workspace you can use PlotTools to quickly create and customize your plot.

The Import Wizard GUI is presented on page:

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f10-61355.html#f10-61402

1 Comment

Lokman Abdullah on 2 Feb 2011

thank you. really helpful

Davide Ferraro

Contact us