Aaron S in Discussions
Letzte Aktivitätam 8 Mär. 2023

Hello I would like to pulse an input species. I read in the forums that repeated assignments can be used for this, but I am not exactly sure how to implement this. This is the MATLAB code that resembles what I would like the input pattern to be: t = 0:1/1e3:60; d = [10:2:30]'; x = @rectpuls; y = pulstran(t,d,x); plot(t,y) hold off xlabel('Time (s)') ylabel('Waveform') Thanks for any help! Aaron Rectangular pulse for input species There's actually a SimBiology example that is quite similar to a pulse: https://www.mathworks.com/help/simbio/ug/deterministic-simulation-of-a-model-containing-a-discontinuity.html Is that close enough to answer your question? Can you tell what you mean by *repeated assignments* more clearly ? Thank you for this. We ended up using events and triggers in the simbiology model builder interface which was a good workaround to what we were aiming for. https://jneurodevdisorders.biomedcentral.com/articles/10.1186/s11689-022-09431-3 simbiology pulse train repeated assignment rate rule
Tetiana Slavnikova in Discussions
Letzte Aktivitätam 12 Nov. 2022

Dear community, I want to develop a fermentation model with 4 ODEs, one of which contains variable y. A "repeated assignment", e. g. y=5x+5, contains variable x that has been measured each second. These data (columns with time and corresponding value x in each row) are recorded in the Excel file. Does anyone have any suggestion how to implement this in symbiology? Thank you very much in advance, Repeated assignment with measured variable Hi Tetiana, You can do this by creating a repeated assignment for x that calls a function to do linear interpolation of the reported experimental values of x. The steps would be: create a function, lets say myfunction, to do linear interplotion of experimentally measured values of x create a repeated assignment for x that calls this custom function, such as: x = myfunction(time). Please see this example for an example of this forcing function strategy. Here, the values of Plasma Ins Conc, Glu Prod, and Glu Appear Rate are controlled by repeated assignments that call such functions. If you type edit PlasmaInsulin in MATLAB command-line you can inspect an example external function for interpolation. Please note that we recommend that the inputs and outputs to custom functions used in SimBiology models to be dimensionless and that's the approach taken in the example I reference above. Fulden Thank you very much Fulden! I have a question to the first step. How can I do the linear interplotion from Excel and import the function in simbiology? I can create a function im Matlab and upload the Excel data, but I have no idea how to do it in Simbiology. Sorry, for the dumb question:) Hi Tetiana, you can call MATLAB functions directly from SimBiology model expressions. You only need to make sure that the function is on MATLAB path or in current directory. You don't need an import. Please let me know if this answers your question. Fulden Thank you! But should I import Excel data in Matlab? Sorry, I'm not very experienced yet 😔 You can import data from Excel to MATLAB using readtable. % Say you have file with name mydata.xlsx, with colums T for time points and X for x values. % You can bring it to MATLAB as a table: data = readtable('mydata.xlsx'); % Save this table in a mat file: save mymatfile.mat data You can then load this data in your custom function: function y = myfunction(time) persistent d % initialize data when time is 0 if time == 0 || isempty(d) d = coder.load('mymatfile.mat'); end y = interp1(d.data.T, d.data.X, real(time)); Please note that you could call readtable from the function directly too but that would not be compatible with code generation which SimBiology let you take advantag of. SimBiology lets you accelerate simulations by converting the model to compiled C code using code generation, which executes faster. Since the MATLAB function readtable is not supported for code generation, I'm not using that within this function. Instead I'm using coder.load to load data from a mat file. Dear Fulden, I’m very very grateful to you! It’s worked out:) repeated assignment
Aaron S in MATLAB Answers
Letzte Aktivitätam 3 Sep. 2021

I would like to pulse an input species in Simbiology. I read in a previous answer that repeated assignments can be used to accomplish this. However, I am unclear how to do this. The following is MATLAB code for generating the pulse that I would like the species concentration to follow: t = 0:1/1e3:60; d = [0:2:60;sin(2*pi*0.05*(0:2:60))]'; x = @rectpuls; y = pulstran(t,d,x); plot(t,y) hold off xlabel('Time (s)') ylabel('Waveform') Output: Any help is appreciated as to how I can accomplish this in Simbiology. Aaron
Richard Allen in MATLAB Answers
Letzte Aktivitätam 21 Jan. 2014

I have a SimBiology model that is 50% ODEs, and 50% Repeated Assignment Rules (i.e. functional relationships). Aside from differentiating them all wrt to time, is there anyway to include variables/parameters that are defined by repeated assignment in the SimBiology diagram?

Info zu SimBiology

A gathering place for scientists working in QSP, PBPK, and PK/PD modeling using SimBiology and MATLAB. Features discussions, shared models and code, and other resources from our global community of users.

Mitwirkende mit den besten Beiträgen

Moderatoren