%% Define Import Options for Variable in Spreadsheet File
% Create an import options object to read one variable from the file patients.xls.
% Initialize a SpreadsheetImportOptions object, specify the variable name, variable type, and the data starting cell. Then, use the preview function with the import options object to preview the data.

opts = spreadsheetImportOptions; 
opts.VariableNames = 'LastName';
opts.VariableTypes = 'categorical';
opts.DataRange = 'A2';
preview('patients.xls',opts)

% Import the variable from the file.

oneVar = readtable('patients.xls',opts);
whos oneVar

% Copyright 2018 The MathWorks, Inc.