readparam

Reads a list of parameter names and values from a file
72 descargas
Actualizado 23 Nov 2018

Ver licencia

Small function to read a list of parameters for a model and return it in a structure, so
it's easy to handle as a unit. I use it quite a bit in my own work. Thought it could be useful for
others.

S= readparam(filename) reads a list of parameter names and values
from a file, either a comma-separated file (csv) or an Excel file (xls).
'filename' is a string with the name of the file. The values are
returned in structure S, with the names of the parameters as field
names. The value of parameter 'par' can be accessed as 'S.par'.

Parameter values can be: scalars, vectors, character strings or function
handlers. Specify vectors with square brackets and separate
the values with spaces (NOT commas). To indicate a character
string put a '#' before the string, just after the comma.
To identify a function handle put a '@' before the function's name.

Parameter names have to be in the first column and the values in the
second column. The first row of the file is not returned, but it cannot
be empty. If the data are in Excel the data has to be in the
first sheet of the file.

P= readparam('readparam.csv')

In the example included, "time", "tstep", "area", "verbose" and
"savesim" are scalars. "temp" is a vector of three values
(do NOT separate the values with commas). "P.odesol" is a function
handle for one of Matlab's ODE solvers. "P.repmod" is a
character string to define some choice within your model.
"P.spcfile" is the name of a file where additional info is stored.

Citar como

Francisco de Castro (2024). readparam (https://www.mathworks.com/matlabcentral/fileexchange/69446-readparam), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2018b
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
1.0.1

Included vectors as data type. Inserted example data in the help.

1.0.0