%% Structure Array Inputs
% Expand a structure argument into name-value pairs.

s.input1 = 10;
s.input2 = 20;
default = 0;

p = inputParser;
addParameter(p,'input1',default)
addParameter(p,'input2',default)
parse(p,s)

p.Results

%
% Accept a structure as a single argument by setting the StructExpand property to false.

s2.first = 1;
s2.random = rand(3,4,2);
s2.mytext = 'some text';

p = inputParser;
p.StructExpand = false;
addRequired(p,'structInput')
parse(p,s2)

results = p.Results
fieldList = fieldnames(p.Results.structInput)

% Copyright 2015 The MathWorks, Inc.