I want to use the Vector.play() method to continuously apply a forcing function. The forcing function I want to use is a sine wave modeled as f(t) = A+B*sin(2*PI*f*t). I am able to use the GUI-based approach for graphing this forcing function, copying it to a clipboard, then using the GUI-based Vector play. But I can't seem to figure out the best way to do this in the hoc code.

My current approach looks like:

Code: Select all

```
1 // Basics of forcing function
2 objref forcefunc, forcetime
3 forcefunc = new Vector()
4 forcetime = new Vector()
5
6 // Create functions
7 proc force_waveform() {
8 forcefunc.resize(6)
9 forcefunc.fill(0)
10
11 forcefunc.x[0] = -5+5*sin(2*PI*2*t)
12 forcefunc.x[1] = -5+5*sin(2*PI*2*t)
13 forcefunc.x[2] = -5+5*sin(2*PI*2*t)
14 forcefunc.x[3] = -5+5*sin(2*PI*2*t)
15 forcefunc.x[4] = -5+5*sin(2*PI*2*t)
16 forcefunc.x[5] = -5+5*sin(2*PI*2*t)
17
18 forcetime.resize(6)
19 forcetime.fill(0)
20 forcetime.x[0] = 15
21 forcetime.x[1] = 16
22 forcetime.x[2] = 17
23 forcetime.x[3] = 18
24 forcetime.x[4] = 19
25 forcetime.x[5] = 20
26 }
27
28 proc attach_force() {
29 forcefunc.play(&node[25].v(0.5), forcetime, 1)
30 }
31
32 proc set_force() {
33 force_waveform()
34 attach_force()
35 }
36 set_force()
```

1. The values assigned to forcefunc are not varying with time since we don't have access to the variable t (as far as I can tell).

2. I'm not sure how to make this "play" throughout the entire duration of the simulation since I don't have access to the timestep or neuron time as the simulation proceeds. I've temporarily filled in values of 15, 16, 17, 18, 19, 20 to make it play just for testing purposes.

Any suggestions?