Simbiology: definining multiple parameters from output of single function
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Michael
am 2 Sep. 2014
Beantwortet: Arthur Goldsipe
am 5 Sep. 2014
I have a function which will calculate the values for multiple parameters within my model in Simbiology. I know I can define a rule that calls functions with a single output and use this to define a parameter value, however I don't know how to do this for multiple parameters.
In Matlab it could be accomplished by:
[par1,par2,par3]=function(a,b,c), where a,b,c are inputs for the function.
However as Simbiology does not allow vectors as parameters this will not work. Alternatively if there was some way to retrieve (say) the 3rd output from the function this would be enough, e.g. par3=function(a,b,c){3}, however as far as I am aware this is not possible.
Any help appreciated.
Thanks
0 Kommentare
Akzeptierte Antwort
Arthur Goldsipe
am 5 Sep. 2014
Hi,
SimBiology doesn't have an easy way to do this. As you guessed, I think the best option is to use get the nth output. There's no built-in MATLAB language notation, so you'll have to use a separate function. Let me try to make this concrete.
Let's say you have the following function you want to use in SimBiology:
[p1, p2, p3] = calcParams(a, b, c);
You could write rules in your model that look like this:
'p1 = nth_output(@calcParams, 1, a, b, c)'
'p2 = nth_output(@calcParams, 2, a, b, c)'
'p3 = nth_output(@calcParams, 3, a, b, c)'
Then you could use the following function for nth_output:
function p = nth_output(funcHandle, N, varargin)
outputs = cell(1,N);
[outputs{:}] = funcHandle(varargin{:});
p = outputs{N};
end
0 Kommentare
Weitere Antworten (0)
Communitys
Weitere Antworten in SimBiology Community
Siehe auch
Kategorien
Mehr zu Extend Modeling Environment finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!