mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 19:17:48 +00:00
76a6216cf7
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.
34 lines
750 B
Matlab
34 lines
750 B
Matlab
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
|
|
|