Kim Ha wrote:I am trying to input a vector which has two column, one is synaptic weight and one is delay time, to Neuron. This vector is created by Matlab and is saved as .txt file.

hoc can do the usual file text I/O. You'll want to read the Programmer's Reference documentation of ropen and fscan, or the File class's methods ropen and scanvar.

when I change the synaptic weight and delay time of the model by loading the data from my above text file (assume that Neuron can read my two-column txt file), I will do the following syntax:

nclist.o(i).delay = vect.x.*[1]*

nclist.o(i).weight = vect.x*[2]*

Are these correct?

*Good question. This raises many issues.*

First, hoc indices start with 0, not 1. Second, a Vector is a 1 dimensional array, so vecname.x*[j] will generate an error message. It is possible to do this*Code: Select all

```
objref vecarray[2]
for i=0,1 vecarray[i]=new Vector()
```

but that gives you an "array" of object references, i.e. objrefs whose names are vecarray[0] and vecarray[1], not a multidimensional array.

Code: Select all

```
oc>for i=0,1 print vecarray[i]
Vector[5]
Vector[6]
```

and the ith element of the jth array would be called vecarray

*.x[j]*

Now I have a couple of questions for you.

Let's suppose that you change this

nclist.o(i).delay = vect.x*[1]*

nclist.o(i).weight = vect.x*[2]*

to this

nclist.o(i).delay = vect[0].x

nclist.o(i).weight = vect[1].x

which means that you have two vectors--vect[0] and vect[1]--where vect[0] contains the delays and vect[1] contains the corresponding weights, so setting up the weights and delays would use this loop:Code: Select all

```
for i=0,nclist.count-1 {
nclist.o(i).delay = vect[0].x[i]
nclist.o(i).weight = vect[1].x[i]
}
```

Would your program be easier to understand if, instead of an array of two Vectors, each of which contains nclist.count elements, you used a List that contains nclist.count Vectors, where each Vector has two elements? If you called this list ncplist (for "NetCon parameter list"), the delay and weight for the ith NetCon would be called ncplist.o(i).x[0] and ncplist.o(i).x[1], respectively. Then to iterate over all NetCons you'd do this:

Code: Select all

```
for i=0,nclist.count-1 {
nclist.o(i).delay = ncplist.o(i).x[0]
nclist.o(i).weight = ncplist.o(i).x[1]
}
```

And if you wanted your programming style to be very mnemonic, you could define a couple of symbolic constants

DELAY = 0

WEIGHT = 1

so your code could look like this

Code: Select all

```
for i=0,nclist.count-1 {
nclist.o(i).delay = ncplist.o(i).x[DELAY]
nclist.o(i).weight = ncplist.o(i).x[WEIGHT]
}
```