mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-31 20:47:51 +00:00
Add a advanced example
It uses its own API which I packed between MTApi5 and MatLab. Possible that this is useless, but errors from the .NET assembly are more tradable.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
function opt=varargin2struct(varargin)
|
||||
%
|
||||
% opt=varargin2struct('param1',value1,'param2',value2,...)
|
||||
% or
|
||||
% opt=varargin2struct(...,optstruct,...)
|
||||
%
|
||||
% convert a series of input parameters into a structure
|
||||
%
|
||||
% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
|
||||
% date: 2012/12/22
|
||||
%
|
||||
% input:
|
||||
% 'param', value: the input parameters should be pairs of a string and a value
|
||||
% optstruct: if a parameter is a struct, the fields will be merged to the output struct
|
||||
%
|
||||
% output:
|
||||
% opt: a struct where opt.param1=value1, opt.param2=value2 ...
|
||||
%
|
||||
% license:
|
||||
% Simplified BSD License
|
||||
%
|
||||
% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
|
||||
%
|
||||
|
||||
len=length(varargin);
|
||||
opt=struct;
|
||||
if(len==0) return; end
|
||||
i=1;
|
||||
while(i<=len)
|
||||
if(isstruct(varargin{i}))
|
||||
opt=mergestruct(opt,varargin{i});
|
||||
elseif(ischar(varargin{i}) && i<len)
|
||||
opt=setfield(opt,varargin{i},varargin{i+1});
|
||||
i=i+1;
|
||||
else
|
||||
error('input must be in the form of ...,''name'',value,... pairs or structs');
|
||||
end
|
||||
i=i+1;
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user