import matrix from file

Particularly useful chunks of hoc and/or NMODL code. May be pedestrian or stunningly brilliant, may make you gasp or bring tears to your eyes, but always makes you think "I wish I had written that; I'm sure going to steal it."
Post Reply
figoyouwei
Posts: 41
Joined: Sun Aug 08, 2010 11:09 am

import matrix from file

Post by figoyouwei »

Dear Ted,

The traditional way to import matrix data from file is to 1. define a matrix and then 2. scanf the file by specifying the number of rows and cols, e.g.

Code: Select all

mat = new Matrix(nrow, ncol)
mat.scanf(fileobj, nrow, nrow)
Is there a way in hoc, which can automatically read in the nrow/ncol information from the file without specifying all the times ?
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: import matrix from file

Post by ted »

Let me refer you to the Programmer's Reference documentation of the Matrix class and its methods, where you will find the answer to your question. See the "Programmer's Reference" link on NEURON's home page http://www.neuron.yale.edu
figoyouwei
Posts: 41
Joined: Sun Aug 08, 2010 11:09 am

Re: import matrix from file

Post by figoyouwei »

thanks ! scanf() with no arguments works perfect.
Post Reply