Vector Variables, Preload, and External matlab functions (in m files) in Simbiology
2 次查看(过去 30 天)
显示 更早的评论
In a previous question, I asked about how to switch between using an ODE-calculated species value, and a forced function fit. In response to some very useful interaction with the Mathworks experts (thank you Arthur), I now have a model with an ODE-calculated species value (x_ODE), a parameter whose value is set by a repeat-assignment-rule parameter (x_forced), a switch (switch_force) and a species whose value is set to either x_ODE or x_forced based upon the switch using a repeat assignment (you could use two repeat assignment rules as well, and select one active and the other not). This node (x_used) is the value used wherever needed (that is, where x_ODE would normally appear).
So I can set x_forced=sin(time) as a test case, and that works. This is a good academic exercise, but few biological functions are based upon a pure sine wave. I'd like to use a spline function set x_forced. So I'd like to use x_forced = spline(tvec, xvec, time), where tvec and xvec are vectors of time and function value, and time is the system variable time.
So, some questions: 1) Can I use vector variables within simbiology? 2) If so, is there a preload function, as in Simulink that I could use to load the vectors to fix the simbiology variable values, prior to simulation? 3) If not, can simulink call external m files, so that my repeat assignment rule would be x_forced = x_external(time) and x_external.m would be an m. function file that (on first call) reads a file, and then (and on subsequent calls) uses the data loaded from the file, and the spline function, to return the value of x at time "time"?
SBML2 only allows for parameter values that are type "double" (SBML 2, section 4.7.2). I believe that this means scalar (parameters are all scalar in Pathway Designer, for example). But biological models sometimes need vector data!
采纳的回答
Arthur Goldsipe
2018-3-15
Currently, SimBiology only supports scalar quantities for species, compartment, and parameter values. However (as you already discovered), you can use arbitrary MATLAB functions in the mathematical expressions you write in SimBiology models. This includes using functions that you write yourself. That is the approach I used for the external forcing functions in the insulin demo mentioned in the previous post. Take a look at the function files EndogenousGlucoseProduction.m, GlucoseAppearanceRate.m, and PlasmaInsulin.m to see how I implemented them.
One note: Although you can use almost any MATLAB function, not all functions or language features are compatible with SimBiology's acceleration feature. As described here, acceleration requires that you restrict yourself to a subset of MATLAB that is compatible with code generation.
0 个评论
更多回答(2 个)
社区
更多回答在 SimBiology Community
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scan Parameter Ranges 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!