mttSetFieldDefault.m 317 B

123456789101112
  1. function structure = mttSetFieldDefault(structure,component,value)
  2. undefined = 0 ;
  3. if isfield(structure,component)
  4. undefined = isempty(getfield(structure,component)) ;
  5. else
  6. undefined = 1 ;
  7. end
  8. if undefined
  9. structure = setfield(structure,component,value) ;
  10. end