This function merges field of struct_a and struct_b, and return merged struct. [USAGE] [m_struct] = vb_merge_struct(<struct_a>, <struct_b>); [IN] struct_a : struct a struct_b : struct b [OUT] m_struct : merged struct Author: rhayashi Created: 2007-07-25 Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [m_struct] = vb_merge_struct(struct_a, struct_b) 0002 % This function merges field of struct_a and struct_b, 0003 % and return merged struct. 0004 % [USAGE] 0005 % [m_struct] = vb_merge_struct(<struct_a>, <struct_b>); 0006 % [IN] 0007 % struct_a : struct a 0008 % struct_b : struct b 0009 % [OUT] 0010 % m_struct : merged struct 0011 % 0012 % Author: rhayashi 0013 % Created: 2007-07-25 0014 % 0015 % Copyright (C) 2011, ATR All Rights Reserved. 0016 % License : New BSD License(see VBMEG_LICENSE.txt) 0017 0018 % 0019 % --- Previous check 0020 % 0021 if ~exist('struct_a', 'var') 0022 error('struct_a is a required parameter.'); 0023 end 0024 if ~exist('struct_b', 'var') 0025 error('struct_b is a required parameter.'); 0026 end 0027 0028 % 0029 % --- Main Procedure 0030 % 0031 var_names_b = fieldnames(struct_b); 0032 for k=1:length(var_names_b) 0033 struct_a.(var_names_b{k}) = struct_b.(var_names_b{k}); 0034 end 0035 m_struct = struct_a;