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

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

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

[Year, Month, DayOfMonth] = readvars('airlinesmall_subset.xlsx','Sheet','2007','Range','A2:C11');
whos Year Month DayOfMonth
disp([Year Month DayOfMonth])

% Copyright 2018 The MathWorks, Inc.