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

2 ビュー (過去 30 日間)
Frank Sommerhage
Frank Sommerhage 2011 年 9 月 15 日
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 コミュニティ

カテゴリ

Help Center および File ExchangeExtend Modeling Environment についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by