![]() ![]() BRAHMS
User Guide » Developing Processes » Quick Start » 1258 » Keeping State
This documentation is offline - click here to go online
Index | Search: Go online to use Search
| ||
OverviewThe Process you've created doesn't have any internal states, so it can only create very uninteresting outputs. Let's add some state variables now, and get some dynamics going. Keeping a stateModify your source file as follows, to add a state, initialise it, and output it on one of our two output channels. M Source Code (against 1258)
case persist
% initialise a state persist
% ok
outputC_OK M Source Code (against 1258)
% write output
output
Matlab Console
>> test
Columns 1 through 7
0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000
0 1.0000 2.0000 3.0000 4.0000 5.0000 6.0000
Columns 8 through 10
0.5000 0.5000 0.5000
7.0000 8.0000 9.0000
Good, now we've got an internal state, and we're sending it out on our output port. Now let's add some dynamics. Modifying internal stateThis is going to be the cell's membrane potential (which we'll model as being between zero and one, so it doesn't get too neuroscience-y). Let's implement its decay back towards zero. We'll also make the sample rate a bit more realistic, moving from 10Hz to 1000Hz, and run for a quarter of a second, so we get some nice behaviour displayed. We'll get 250 samples logged, now, so we'll plot the output log instead of just displaying it to console. Modify source file and test script as shown below. M Source Code (against 995)
% add process
state
fS cls addprocess M Source Code (against 995)
M Source Code (against 995)
% show output
disp figure t plot xlabel ylabel (The M Source Code (against 1258)
case persist
% run dynamics tau fS lambda persist
% write output
Which should generate a plot something like this one. ![]() Where do I go from here?This is entirely up to you. You can keep as much state as you like, in the same way as shown above. |
||
This is a documentation page for the BRAHMS Modular Execution (Simulation) Framework. For details of licensing and distribution, please click here. To advise of an error or omission, please click here. |