![]() ![]() BRAHMS
User Guide » Developing Processes » Quick Start » 1199 » 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. C++ Source Code (against 1199)
// an (numeric) output port
numeric
// our internal state DOUBLE currentMembranePotentialC++ Source Code (against 1199)
// extract DataML
EventStateSet EventStateSet XMLNode xmlNodeDataMLNode nodeState// initialise our internal state currentMembranePotential
// ok
return C_OK C++ Source Code (against 1199)
// it's got two elements, so let's write them both
p pMatlab 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 C++ Source Code (against 1199)
case EVENT_RUN_SERVICE
// run dynamics currentMembranePotential
// get a pointer to the port's contents (actual numeric data)
DOUBLE DOUBLE 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. |