mttCheckStateDeclarations.m 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. function mttCheckStateDeclarations(model)
  2. for i = 1:length(model.sympar)
  3. mttAssert(~ismember(model.sympar{i},model.state),...
  4. ['Same name (',model.sympar{i},') used for "state" and "abg[...]" parameters']) ;
  5. end
  6. for i = 1:length(model.numpar)
  7. mttAssert(~ismember(model.numpar{i},model.state),...
  8. ['Same name (',model.numpar{i},') used for "numpar" and "state" parameters']) ;
  9. end
  10. for i = 1:length(model.input)
  11. mttAssert(~ismember(model.input{i},model.state),...
  12. ['Same name (',model.input{i},') used for "input" and "state" parameters']) ;
  13. end
  14. for i = 1:length(model.state)
  15. mttAssert(~ismember(model.state{i},model.sympar),...
  16. ['Same name (',model.state{i},') used for "state" and "abg[...]" parameters']) ;
  17. mttAssert(~ismember(model.state{i},model.numpar),...
  18. ['Same name (',model.state{i},') used for "state" and "numpar" parameters']) ;
  19. mttAssert(~ismember(model.state{i},model.input),...
  20. ['Same name (',model.state{i},') used for "state" and "input" parameters']) ;
  21. end
  22. all_parameters = [] ;
  23. if ~isempty(model.sympar)
  24. all_parameters = model.sympar ;
  25. end
  26. if ~isempty(model.numpar)
  27. if isempty(all_parameters)
  28. all_parameters = model.numpar ;
  29. else
  30. all_parameters = [all_parameters, model.numpar] ;
  31. end
  32. end
  33. if ~isempty(model.input)
  34. if isempty(all_parameters)
  35. all_parameters = model.input ;
  36. else
  37. all_parameters = [all_parameters, model.input] ;
  38. end
  39. end
  40. for j = 1:length(all_parameters)
  41. current_parameter = all_parameters{j} ;
  42. mttAssert(~ismember(current_parameter,model.state),...
  43. ['Repeated parameter/state name "',current_parameter,'"']) ;
  44. end
  45. for j = 1:length(model.state)
  46. current_state = model.state{j} ;
  47. mttAssert(~ismember(current_state,all_parameters),...
  48. ['Repeated parameter/state name "',current_state,'"']) ;
  49. end