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.
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