%% Read Matrix from Specified Sheet and Range Using Import Options
% 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)

% Configure the values in the opts object to import 10 rows for the first five variables from the worksheet named '2007'.

opts.Sheet = '2007';
opts.SelectedVariableNames = [1:5]; 
opts.DataRange = '2:11';
M = readmatrix('airlinesmall_subset.xlsx',opts)

% Copyright 2018 The MathWorks, Inc.
%
%