%% Define Import Options for Multiple Variables in Spreadsheet File
% Create an import options object to read multiple variables from patients.xls.
% Based on the contents of your file, define the number of variables, variable names, variable types, and the data starting location.

numVars = 7;
varNames = {'LastName','Gender','Age','Location','Height','Weight','Smoker'} ;
varTypes = {'char','categorical','int32','char','double','double','logical'} ;
dataStartLoc = 'A2';

% Initialize the import options object opts using the spreadsheetImportOptions function and your variable information.

opts = spreadsheetImportOptions('NumVariables',numVars,...
                                'VariableNames',varNames,...
                                'VariableTypes',varTypes,...
                                'DataRange', dataStartLoc); 

% Preview the data using the preview function with the import options.

preview('patients.xls',opts)

% Import the data using readtable.

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

% Copyright 2018 The MathWorks, Inc.