readParameterFile
readParameterFile reads a parameter file and upload the parameters into a
cell list.
Exemples:
Supose we have a program that needs 3 parameters:
powerValue
powerUnit
numberOfDogs
Copy the next 3 lines into a txt file named: exampleParameters.txt
powerValue=100;
powerUnit=Watts;
numberOfDogs=3;
Note that the parameter file must have this pattern:
name1=Value1;
name2=Value2;
name3=Value3;
.
.
.
%comments can be made using '%'
Now use the command:
parameters = readParameterFile('C:\whateverPath\...\exampleParameters.txt');
The variable parameters will be a cell list:
parameters = powerValue
100
powerUnit
Watts
numberOfDogs
3
To "ask" for the power unit, we use:
a = parameters{4};
a = 'watts'
Note that you must know previously the 'order' of the parameters.
Also note that all the variables are strings (text). If we want to use, for
example, '100' as a number, we shall use str2num or str2double:
b = str2num(parameters{6});
b = 3
Cite As
Carlos Galdino (2026). readParameterFile (https://se.mathworks.com/matlabcentral/fileexchange/54063-readparameterfile), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
readParameterFile/
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0.0 |
