%% Read Matrix from Specified Sheet and Range
% Preview the data from a spreadsheet file and import numerical data, as a matrix, from a specified sheet and range.
% The spreadsheet file airlinesmall_subset.xlsx contains data in multiple worksheets for years between 1996 and 2008.  Each worksheet has data for a given year. Preview the data from file airlinesmall_subset.xlsx. The preview function shows data from the first worksheet by default. The first eight variables in the file contain numerical data.

opts = detectImportOptions('airlinesmall_subset.xlsx');
preview('airlinesmall_subset.xlsx',opts)

% Import 10 rows of the first 5 variables from the worksheet named '2007'.

M = readmatrix('airlinesmall_subset.xlsx','Sheet','2007','Range','A2:E11')

% Copyright 2018 The MathWorks, Inc.