How to output reaction rates for each time step in Simbiology?

조회 수: 2 (최근 30일)
Hi all,
I would like to see the calculated rates between species for each time step. Simbiology doesn't seem to have a function/option to do that (Please correct me if I'm wrong!). How can I get to my rates anyway?
Thanks, Frank

채택된 답변

Frank Sommerhage
Frank Sommerhage 2011년 9월 22일
Thank you for your suggestions. They are definitely a good way to get one or two rates out of rather small models that do not have too many reactions pulling and pushing on one species.
I looked a little deeper into that problem and came up with a quick-'n'-dirty solution of my own. The function rateout.m records all reaction rates over time and exports the result into Matlab's workspace. Detailed instructions are in the file, which is now available in Matlab's File Central at:

추가 답변 (2개)

Arthur Goldsipe
Arthur Goldsipe 2011년 9월 16일
Hi Frank,
Unfortunately, SimBiology does not currently provide direct access to the calculated rates. There are a couple of options for working around this limitation. If you are interested in the total rate of change of a species, then the easiest way to estimate that is probably by finite-differencing the simulation results. For example:
m1 = sbiomodel('example');
c = m1.addcompartment('c');
s = m1.addspecies('s', 100);
k = m1.addparameter('k', 0.5);
r = m1.addreaction('s -> null', 'ReactionRate', 'k*s');
[t1,y1] = sbiosimulate(m1);
dy_dt = diff(y1) ./ diff(t);
Or if you have a few reactions that you want to know the rate of, you can calculate them directly from the rate expression. You can either add this result directly to the simulation results by creating a repeated assignment rule or by calculating it after the simulation. For example, continuing from the example above:
% rate = k*s
rate1 = k.Value*y1;
% Or add a repeated assignment
m1.addparameter('rate', 'ConstantValue', false);
m1.addrule('rate = k*s', 'repeatedAssignment');
[t2, y2] = sbiosimulate(m1);
rate2 = y2(:,2);
% Compare the approaches
plot(t1(1:end-1),-dy_dt, 'x-', t1, rate1, 'o-', t2, rate2, '+-')
Hopefully that is a sufficient workaround. Good luck!
-Arthur
  댓글 수: 3
Frank Sommerhage
Frank Sommerhage 2019년 4월 11일
Hi Sergey,
After I got the above answer in 2011, I wrote a tool to export the reaction rates for each time step. It worked well with versions from back in 2011 and 2012, but then I stopped working with SimBiology and did not update the code. The last I heard was that SimBiology includes an option to export the reaction rates by now, but I might be wrong. If it is still not included, download my old tool from MetlabCentral and try to tweak it for 2019.
Good Luck,
Frank
Sergey Kryazhimskiy
Sergey Kryazhimskiy 2019년 4월 11일
Hi Frank,
Thanks! Yes, I saw your code and will try now to get it to work in 2019a. But I was indeed hoping that there would be a built-in function.

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


Aditya
Aditya 2013년 2월 19일
편집: Aditya 2013년 2월 19일
Hello,
This piece of code was working marvelously in the older version of Matlab. I just updated to a newer version and its not doing its thing.
It is unable to obtain the reaction rates from the rateout rule into the matlab workspace. To be specific it is not declaring the rate as a global variable any more.
Is there is a work around for this?
Thanks,
Aditya

커뮤니티

더 많은 답변 보기:  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