XLSREAD - From Excel to Matlab

xlsread (lower case) is a built in function in Matlab that allows you to somewhat easily transfer information from an Excel spreadsheet to a Matlab variable.

xlsread

Warning: xlsread will probably not work on linux machines. If you are using Linux, try saving the Excel file as a tab separated text file and then use the textread command.

xlsread is a function which reads all the numeric and text (alphabet/words) information from a xls file into variables in the Matlab environment. For simple purposes, those files without text headers and with only one column of data, the useage is simple

        
          data = xlsread('file_name.xlsx'); % xls or xlsx should work
        
      

The column of data will be stored in the data array. The data variable can then be used as any other variable.


Multiple Columns of Data

When multiple columns of data exist, the data variable will be a 2 dimensional matrix. Below is an example assumes the xls file has two columns of data and then creates two variables for that data:

        
          data = xlsread('two_column_file.xlsx');

          first_column = data(:,1);
          second_column = data(:,2);

          % for example for a list of points with x values in the first column
          % and y values in the second column, you would use:

          data = xlsread('shock_tower_pts.xlsx'); % two columns of data

          xs = data(:,1);
          ys = data(:,2);

          % and for example you might want to plot this data:

          plot(xs,ys);

        
      

Back to Topics List