mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 11:07:48 +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,32 @@
|
||||
function val=jsonopt(key,default,varargin)
|
||||
%
|
||||
% val=jsonopt(key,default,optstruct)
|
||||
%
|
||||
% setting options based on a struct. The struct can be produced
|
||||
% by varargin2struct from a list of 'param','value' pairs
|
||||
%
|
||||
% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
|
||||
%
|
||||
% $Id: loadjson.m 371 2012-06-20 12:43:06Z fangq $
|
||||
%
|
||||
% input:
|
||||
% key: a string with which one look up a value from a struct
|
||||
% default: if the key does not exist, return default
|
||||
% optstruct: a struct where each sub-field is a key
|
||||
%
|
||||
% output:
|
||||
% val: if key exists, val=optstruct.key; otherwise val=default
|
||||
%
|
||||
% license:
|
||||
% Simplified BSD License
|
||||
%
|
||||
% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
|
||||
%
|
||||
|
||||
val=default;
|
||||
if(nargin<=2) return; end
|
||||
opt=varargin{1};
|
||||
if(isstruct(opt) && isfield(opt,key))
|
||||
val=getfield(opt,key);
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user