Is there an object associated with simulate task in the simbiology desktop that contains the name of the task?

4 views (last 30 days)
I use State_Subplots in "Plots to Generate" in simbiology simulation tasks a lot. "Plots to Generate" allows scripts to be used on simulation outputs. State subplot gives all the model outputs for species and parameters taht one choses, in separate subplots with time as abscissa. But when I run two different tasks (each with a different name signifying, for example, different variants) , each plot generated is labeled "State Subplot - Figure x". Like this:
This can get confusing - aboslutely nothing differentiates these plots!. Ideally, the tabs generated would show the task name used to generate them. For example, "Subplots - Mass Balance" and "Subplots - Energy Balance" for tasks named Mass and Energy Balance. Alternately, if I could access the task name I could put that name on the plot with sgtitle. The only objects returned to the workspace by the simulate task seem to be tobj (which contains states and parameters) and obj (which contains the model). There is no "task" object which presumably could contain the unique name for the task. For some "Plots to Generate" scripts there exists a taskresult object, but I see no documentation on what it contains, and it doesn't appear to be generated by the simulation task.
Also, its not clear where/how the tab names for the plots generated by the "Plots to generate" are specified.
So I'm asking
1) is there a task object which contains the name of the simulation task accessible within the "Plots to Generate" script?
2) Is there a way to specify "Plots to Generate" tab names?
If there is a task object with the name, at least this could use the sgtitle matlab function to put a name over the subplots. But ideally, I'd like to be able to add
tname = taskresults.taskname;
figuretab = tname;
This would allow me to keep results straight when I have a few tasks on the screen.
The following is a related, but different suggestion:
An approach which might be useful to users would be to have plot_group objects. So I could (for example) set up a live plot with the variables I want, and then could save the list as a plot_group. plot_groups would contain variables, external data, and math constructs, with the order being signficant. I could run a simulation with the "mass balance" plot group specified in live plots. If that worked, I could specify (for example) "glucose_balance" in live plots and would see the new group of variables without resimulation. Suppose that glucose was balanced. I could then look at the PK plot_group. The model matches the data? Great. Now "PD". Whoops, we've got a problem! I could then look at "mechanism" or other plot_groups to diagnose stuff. All without resimulation. Plus, if you created another task, it would be easy to specify the variables you want in the live view plot.
Right now, I have to create a separate task for each view (live view and state subplots, specified above). Then I have to run the model once per task. Then, if I change the states I want in the subplot, I I have to go back and change every task manually. I think that this could be improved to be more useful and efficient for the user. Thanks!

Accepted Answer

Sietse Braakman
Sietse Braakman on 6 Mar 2019
Hi Jim,
These are good questions.
  • Currently, there is no way to access the task name from the desktop, or from MATLAB. One solution you could explore is create scripts for your tasks that you run in MATLAB, rather than running the tasks in SimBiology. As you might know, for each task you can access the task code by clicking Task Code --> View task code. The task code will be a MATLAB function that you can adjust to your needs. E.g. you could give it a task name - or derive a task name from a variant name - and use that to label your plots.
  • You can dock plots and change the name of the tabs using the following code:
set(0,'DefaultFigureWindowStyle','docked') % set default graphics options to dock plots
% change name of plot tab/figure, remove numbered figures
fig = figure('Name','Subplot State 1','NumberTitle','off');
% plot some SimBiology state simulation
% create the next tab.
fig2 = figure('Name','Subplot State 2','NumberTitle','off');
% return to normal plotting:
More info here:
If I understand your idea of plot groups correctly, these are groups of species you would like to plot together? So the group of mass balance plot group would contain all the species that represent masses in your model, plus e.g. a sum of masses. If so, this is currently not possible in the SimBiology desktop. However, you could write a script that groups your species by their indices use those as an input for a simulation or plotting task (providing you logged the species for each of the plot groups during your first simulation). Or you could plot all your species in a single figure and hide/show only those that belong to a certain plot group using their handle.
Thanks for your valuable suggestions, we will take these on board and investigate how we might implement these in the future. Best,
Jim Bosley
Jim Bosley on 6 Mar 2019
PS I've added sorting to state_subplot to get a State_SubplotSort script. Probably obvious, but may be useful to others:
function State_SubplotSort(tobj, y)
%STATE_SUBPLOT Plots states in separate subplots
% Plots states in separate subplots
% Get Data to be plotted - y is the list of variables to plot
% Apparently output is of form [t,y,names]
if strcmpi(y, '<all>')
[time, data, names] = getdata(tobj);
yy = sort(y); % All I did was add this line and the next... JRB
y = yy;
[time, data, names] = selectbyname(tobj, y);
rootnplots = sqrt(numel(names));
nrows = round(rootnplots);
ncolumns = ceil(rootnplots);
for i = 1:numel(names)
plot(time, data(:,i));

Sign in to comment.

More Answers (0)


More Answers in the  SimBiology Community

Community Treasure Hunt

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

Start Hunting!