%% Read Variables from Specified Sheet and Range using Import Options
% Preview the data from a spreadsheet file and import columns of data from a specified sheet and range as separate variables.
% 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.

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

% Configure the values in the opts object to import 10 rows for the columns 5 and 6 of the worksheet named '2007'.

opts.Sheet = '2007';
opts.SelectedVariableNames = [5 6]; 
opts.DataRange = '2:11';
[DepTime,CRSDepTime] = readvars('airlinesmall_subset.xlsx',opts);

% Display the variables.

[DepTime, CRSDepTime]

% Copyright 2018 The MathWorks, Inc.