Parsing undefined variables in the Simbiology toolbox
Mostrar comentarios más antiguos
The short version is that I have a model with 800+ reactions in it, plus a lot of rules, parameters, etc. and the first 85% was built by someone else completely through the GUI.
Right now there are a lot of undefined variables in the rules, and I need to define them as parameters. It's painfully tedious through the GUI, but I can't figure out how to parse the undefined variable names out of the model so that I can use a script to run addparameter() to define them.
This is my first time using a toolbox and the code capture tool has been helpful, however in this particular instance if I update the undefined variable from the GUI menu, it only displays addparameter() with the name string already included, as well as set() to update the rule.
This is what I'm thinking right now:
%Loop through rules
for i = low:high
% Parse undefined variables from m1.Rules(i)
name_string = ??
p = addparameter(m1, 'name_string', 1.0);
% Assign variable name to object.
rule1 = m1.Rules(i);
% Configure properties.
set(rule1, 'Rule', 'equation' );
end
Any help would be appreciated, either advice on my approach or a different one all together.
Thanks for reading.
-Adam
Edit: I have made some progress and there is a solution in sight.
Here is my current code.
% Load SimBiology project.
out = sbioloadproject();
m1 = out.m1;
r1 = get(m1.Rules, 'Rule');
n_r = length(r1);
for i = 1:n_r
pName = get(m1.Parameters, 'Name');
cr1 = char(r1(i))
v1 = regexp(cr1,'\w*','match');
sz = length(v1);
for j = 1:sz
% compare elements in v1 to elements in pName
% use addparameter() for unfound variable names
end
end
Any advice on comparing the character names is appreciated.
Respuesta aceptada
Más respuestas (0)
Comunidades de usuarios
Más respuestas en SimBiology Community
Categorías
Más información sobre Import Data en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!