Home > utils > struct2keyval.m

struct2keyval

PURPOSE ^

Converts a structure into a cell array that can be used as a series of

SYNOPSIS ^

function outcell = struct2keyval(instruct)

DESCRIPTION ^

 Converts a structure into a cell array that can be used as a series of
 key/value pairs that can be passed into functions, i.e. as varargin

 outcell = struct2keyval(instruct);

 outcell is a 1 X N cell array where N is twice the number of fields in
 the structure instruct.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function outcell = struct2keyval(instruct)
0002 % Converts a structure into a cell array that can be used as a series of
0003 % key/value pairs that can be passed into functions, i.e. as varargin
0004 %
0005 % outcell = struct2keyval(instruct);
0006 %
0007 % outcell is a 1 X N cell array where N is twice the number of fields in
0008 % the structure instruct.
0009 
0010 % 09Sep2016 Petr Janata
0011 
0012 outcell = [fieldnames(instruct)'; struct2cell(instruct)'];
0013 outcell = outcell(:)';
0014 
0015 end

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003