How can I use a Matlab function in SimBiology?

4 views (last 30 days)
Hi,
I am building a model in SimBiology, in which I would like to add the green reactions of the diagram below. The reaction Th0_act (deg_Th0F1) is a first order process which depends on Th0, but also needs the presence of MACR_act or DC_act.
I do not know the specific quantity of MACR_act or DC_act consumed for the Th0_act reaction, but I do know that it is necessary to have at least one unit of any of the two species to make the system work. At that point, I would like to use the following APC.m matlab function in my SimBiology model:
%%APC presentation
function presentation = APC(MACR_act, DC_act)
presentation=0;
if MACR_act>0
presentation=1;
elseif DC_act>0
presentation=1;
end
And I would like to multiply my ReactionFlux7 by my APC.m output (presentation= 1 or 0) to proceed or not with the reaction.
d(Th0_act)/dt = 1/Lymph_node*(ReactionFlux7 - ReactionFlux8)
ReactionFlux7 = deg_Th0F1.kdeg_Th0*F1*Th0
ReactionFlux8 = (degTh0_act.kdeg_Th0*Th0_act)*Lymph_node
I would appreciate any help about how to implement the function in my model.
Thank you in advance,
Violeta

Accepted Answer

Arthur Goldsipe
Arthur Goldsipe on 2 May 2017
Hi Violeta,
I will first directly answer your question and then provide an alternate solution.
First, to use your function APC in SimBiology, all you need to do is save the function to a file named APC.m and ensure that file is in the current working directory or on the MATLAB path. Then, you can use it in your model the same way you use any other MATLAB function. Specifically, you can change the reaction rate kdeg_Th0*F1*Th0 to APC(MACR_act,DC_act)*kdeg_Th0*F1*Th0.
However, you need to be careful whenever your model contains discontinuities, such as the change in APC between 0 and 1. As we describe in this example, you need to include events in your model if you want to accurately solve the equations when there are discontinuities. For your specific case, you can do everything you need without the need to create a file APC.m. Specifically, you can create a parameter presentation with initial value of 0 or 1 as appropriate, make sure it is marked as not constant, and add events that change the value of presentation between 0 and 1:
  • When MACR_act > 0 | DC_act > 0, then presentation = 1
  • When ~(MACR_act > 0 | DC_act > 0), then presentation = 0
Let me know if you have additional questions.
-Arthur
  1 Comment
Violeta Balbas Martinez
Violeta Balbas Martinez on 2 May 2017
Edited: Violeta Balbas Martinez on 2 May 2017
Hi Arthur,
Thank you very much for the reply and for the comments.
It has been very helpful!
Regards Violeta

Sign in to comment.

More Answers (0)

Categories

Find more on Scan Parameter Ranges in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!