mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-29 03:27: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,33 @@
|
||||
function s=mergestruct(s1,s2)
|
||||
%
|
||||
% s=mergestruct(s1,s2)
|
||||
%
|
||||
% merge two struct objects into one
|
||||
%
|
||||
% authors:Qianqian Fang (fangq<at> nmr.mgh.harvard.edu)
|
||||
% date: 2012/12/22
|
||||
%
|
||||
% input:
|
||||
% s1,s2: a struct object, s1 and s2 can not be arrays
|
||||
%
|
||||
% output:
|
||||
% s: the merged struct object. fields in s1 and s2 will be combined in s.
|
||||
%
|
||||
% license:
|
||||
% Simplified BSD License
|
||||
%
|
||||
% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab)
|
||||
%
|
||||
|
||||
if(~isstruct(s1) || ~isstruct(s2))
|
||||
error('input parameters contain non-struct');
|
||||
end
|
||||
if(length(s1)>1 || length(s2)>1)
|
||||
error('can not merge struct arrays');
|
||||
end
|
||||
fn=fieldnames(s2);
|
||||
s=s1;
|
||||
for i=1:length(fn)
|
||||
s=setfield(s,fn{i},getfield(s2,fn{i}));
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user