On National Teacher Day, meet the 2024-25 Kenan Fellows
Import/Export data in Matlab
1. PREPARED By: CHING’TONY MBUMA
IMPORTING/EXPORTING DATA FROM EXCEL
Importing data into MATLAB from Excel can be done in the following way,
I. First make sure the Excel file you wish to import is in the current working
directory. E.g. C:UsersbuqDocumentswork
II. Then open the Matlab
III. After opening the Matlab click to open the M-file
IV. Then type this command at the prompt in the M-file
>>num = xlsread ('filename')
V. Save and Run the M-file
MATLAB will read in the Excel data and assign it to the variable name of your
choice. For this command to work properly it is important that there be no text data
in the Excel file, only rows and columns of numbers.
Example:
The following excel data were imported to the Matlab and the result was shown
below.
2. After entering the below command into the Matlab M-file
>>clear
>>clc
>>num=xlsread(‘our work’)
3. Then, by saving and run the above command the output was as shown below: