Home > functions > internal > dsOptions2Keyval.m

dsOptions2Keyval

PURPOSE ^

OPTIONS2KEYVAL - Convert from options structure to a list of key/value pairs.

SYNOPSIS ^

function keyval = dsOptions2Keyval(options)

DESCRIPTION ^

OPTIONS2KEYVAL - Convert from options structure to a list of key/value pairs.

 Usage:
   keyvals = dsOptions2Keyval(options)

 Inputs:
   - options: options structure to convert

 See also: dsCheckOptions

 Author: Jason Sherfey, PhD <jssherfey@gmail.com>
 Copyright (C) 2016 Jason Sherfey, Boston University, USA

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function keyval = dsOptions2Keyval(options)
0002 %OPTIONS2KEYVAL - Convert from options structure to a list of key/value pairs.
0003 %
0004 % Usage:
0005 %   keyvals = dsOptions2Keyval(options)
0006 %
0007 % Inputs:
0008 %   - options: options structure to convert
0009 %
0010 % See also: dsCheckOptions
0011 %
0012 % Author: Jason Sherfey, PhD <jssherfey@gmail.com>
0013 % Copyright (C) 2016 Jason Sherfey, Boston University, USA
0014 
0015 % Grab the field names
0016 fields = fieldnames(options);
0017 keyval = {};
0018 
0019 % Loop over the field names, grab the value, and append both to the output
0020 % list of key/value pairs
0021 for i=1:length(fields)
0022   keyval{end+1} = fields{i};
0023   keyval{end+1} = options.(fields{i});
0024 end;

Generated on Tue 12-Dec-2017 11:32:10 by m2html © 2005