Rank: 357142 based on 0 downloads (last 30 days) and 0 file submitted
photo

batman52

E-mail

Personal Profile:

 

Watch this Author's files

 

Comments and Ratings by batman52 View all
Updated File Comments Rating
09 Mar 2012 parseargs: Simplifies input processing for functions with multiple options For parsing function arguments supplied as name-value pairs, e.g. 'XLim',[0 10],'YLim',[0 100] Author: Malcolm Wood

I am trying this, but it's not passing the argcheck of inputParser...

function [varargout] = struct2varargin(instruct)

fields = fieldnames (instruct);
values = struct2cell (instruct);

varargout = {};
% length(fields)
% length(values)

for idx =1:length(values)
varargout{2*idx-1} = char(fields{idx});
varargout{2*idx} = values{idx};
end

end

09 Mar 2012 parseargs: Simplifies input processing for functions with multiple options For parsing function arguments supplied as name-value pairs, e.g. 'XLim',[0 10],'YLim',[0 100] Author: Malcolm Wood

Does it exist somewhere, the inverse function for this?

What I need to do is:

f_setstate('param1',p1val,'param2',p2val)
savestate = f_getstate();
f_setstate(struct2varargin(savestate))

Input parameters for f_setstate has to be pv pairs, because i am using inputParser to parse it.
At the same time, I like savestate being a structure, because it's easier to hanlde than pv pairs.

Contact us