readparam

Reads a list of parameter names and values from a file
74.0 次下载
更新时间 2018/11/23

查看许可证

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.

引用格式

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

MATLAB 版本兼容性
创建方式 R2018b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Text Files 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.1

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

1.0.0