Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Help to write a loop for SimBiology

Subject: Help to write a loop for SimBiology

From: Jerry

Date: 21 Nov, 2012 15:45:08

Message: 1 of 2

Hello,

I do have a model composed of 10 components and 16 parameters. I simulated the model and I got the outputs. But, in the next runs I would like to modify only three out of 16 parameters, including {'kn','ko','kp'}.

Here is the command line that considers only parameters that need to be modified

MParam= sbioselect (model, 'Type', 'parameter', 'Where', 'Name', '==', ...
    {'kn','ko','kp'});

So there are 17 different values:
values = [0 5e-07 1e-06 5e-06 1e-05 5e-05 0.0001 0.0005 0.001 0.005 0.01 0.05 0.1 0.5 1 5 10];

Now, I would like to create all possible three combinations of these values:
AllParams = nchoosek(values, 3)

At each run, the parameters {'kn','ko','kp'} would take any given row of "AllParams" so at the end there should be 680 or ["1:size(AllParams, 1)"] different runs.

May someone help me to write this loop and create 680 different "sbiosimulate"?

Thanks,
Jerry

Subject: Help to write a loop for SimBiology

From: Ricardo Paxson

Date: 22 Nov, 2012 15:56:08

Message: 2 of 2

Hello,

There are a few ways to do this, I will show you the most straight forward way:

**************
function results = scanParameters(model, values, parameterNames)

MParam= sbioselect (model, 'Type', 'parameter', 'Where', 'Name', '==', ...
    parameterNames);

for i = 1:size(values, 1)
    for j = 1:numel(MParam)
        MParam(j).Value = values(i, j);
    end
    
    try
        results(i) = sbiosimulate(model);
    catch
        sprintf('Simulation failed for values %d', values(i, :));
    end
end
*********************

This can be improved a bit but I hope it show how you can do this. It can be improved by doing some error checking, for example I assumed that values for the parameters are in rows but did not check.

Note that it is possible that a simulation will fail for some parameter values so I wrapped the call to sbiosimulate in a try catch.

The returned value is an array of objects that have your simulation values.

For example if the return is called 'results' you can plot things like this for the first simulation:

t = results(1).time;
x = results(1).data;

plot(t, x)

I hope this helps. Let me know if you have further questions.

-pax

"Jerry " <jerrycholo@gmail.com> wrote in message <k8isu4$nij$1@newscl01ah.mathworks.com>...
> Hello,
>
> I do have a model composed of 10 components and 16 parameters. I simulated the model and I got the outputs. But, in the next runs I would like to modify only three out of 16 parameters, including {'kn','ko','kp'}.
>
> Here is the command line that considers only parameters that need to be modified
>
> MParam= sbioselect (model, 'Type', 'parameter', 'Where', 'Name', '==', ...
> {'kn','ko','kp'});
>
> So there are 17 different values:
> values = [0 5e-07 1e-06 5e-06 1e-05 5e-05 0.0001 0.0005 0.001 0.005 0.01 0.05 0.1 0.5 1 5 10];
>
> Now, I would like to create all possible three combinations of these values:
> AllParams = nchoosek(values, 3)
>
> At each run, the parameters {'kn','ko','kp'} would take any given row of "AllParams" so at the end there should be 680 or ["1:size(AllParams, 1)"] different runs.
>
> May someone help me to write this loop and create 680 different "sbiosimulate"?
>
> Thanks,
> Jerry

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us