mttUpdateBondDomain.m 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. function [model,bond_not_failed] = mttUpdateBondDomain(...
  2. model,bond_number,imposed_domain,imposed_domain_item)
  3. if isempty(bond_number)
  4. bond_not_failed = 1 ;
  5. else
  6. [model.bond(bond_number).domain,domain_ok] = ...
  7. update_domain(model.bond(bond_number).domain,imposed_domain) ;
  8. if domain_ok
  9. [model.bond(bond_number).domain_item,domain_item_ok] = ...
  10. update_domain_item(model.bond(bond_number).domain_item,imposed_domain_item) ;
  11. else
  12. domain_item_ok = 0 ;
  13. end
  14. bond_not_failed = domain_ok & domain_item_ok ;
  15. end
  16. function [value,ok] = update_domain(value,new_value)
  17. ok = 1 ;
  18. if ~isempty(new_value)
  19. if isempty(value)
  20. value = new_value ;
  21. else
  22. ok = value==new_value ;
  23. end
  24. end
  25. function [value,ok] = update_domain_item(value,new_value)
  26. ok = 1 ;
  27. if ~isempty(new_value)
  28. if isempty(value)
  29. value = new_value ;
  30. else
  31. ok = strcmp(value,new_value) ;
  32. end
  33. end