%% Set Options for Selected Variables
% Create an import options object, set the options for selected variables, and import the data using the tailored options and the readtable function.
% Create an options object for the spreadsheet patients.xls.

opts = detectImportOptions('patients.xls');

%
% Set the FillValue property for the Smoker, Diastolic, and Systolic variables.

opts = setvaropts(opts,'Smoker','FillValue',false);
opts = setvaropts(opts,{'Diastolic','Systolic'},'FillValue',0);

%
% Select the variables you want to import.

opts.SelectedVariableNames = {'Smoker','Diastolic','Systolic'};

%
% Import the variables and display a summary.

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

% Copyright 2012 The MathWorks, Inc.