How to use the 'exist' function for a SimBiology built-in function?

조회 수: 2 (최근 30일)
SimBiology has a kinetic law built-in called 'MassAction'. I want to use 'exists' to detect whether it is in there or not (then I'll use it in an if formula). Simply using 'exists('MassAction')' does not work as it gives a negative even though I know it is there. Does anybody know how I can get this to work?
Thanks

채택된 답변

Arthur Goldsipe
Arthur Goldsipe 2015년 1월 8일
Hi Ciaran,
The list of built-in and user-defined kinetic laws are stored on something called the SimBiology root object. You can access is with the sbioroot function. For example, here is sample code to get lists of the kinetic laws:
root = sbioroot;
userDefinedLaws = root.UserDefinedLibrary.KineticLaws;
builtinLaws = root.BuiltinLibrary.KineticLaws;
Alternatively, if you want to search for a kinetic law with a particular name, you can use the sbioselect. For example, here's how you could use sbioselect to find the MassAction kinetic law:
lawList = sbioselect('Name', 'MassAction', 'Type', 'abstract_kinetic_law')
If the output from calling sbioselect is empty, then the kinetic law with the specified name has not been added to the library. If you leave out the 'Type', 'abstract_kinetic_law' part of the command, you'll find all SimBiology objects with the specified name. You can read more about sbioselect here. And here is a list of all the Type values used in SimBiology, in case you ever want to search through the names of other types of objects.

추가 답변 (1개)

Arthur Goldsipe
Arthur Goldsipe 2015년 1월 8일
Hi Ciaran
The MassAction kinetic law is always included in SimBiology, so you can always use it in a SimBiology model. It's also possible to search for or verify the existence of a built-in or user-defined kinetic law. If you can clarify how/why you need that information to use it in a formula, then someone can show you how to get that information if it's really necessary.
-Arthur
  댓글 수: 2
Ciaran
Ciaran 2015년 1월 8일
Hi Arthur,
Essentially I am having difficulty defining a new kinetic law. I wanted to use an 'if' formula to add to the user defined library if it does not already exist (in attempt to get around a paradoxical error that I am getting). The 'MassAction' I know exists so I was using it to test the 'exists' function.
Thanks
Arthur Goldsipe
Arthur Goldsipe 2015년 1월 8일
Ok, that makes sense. I'll add a new answer that describes a couple of ways to do this.

댓글을 달려면 로그인하십시오.

커뮤니티

더 많은 답변 보기:  SimBiology Community

카테고리

Help CenterFile Exchange에서 Extend Modeling Environment에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by