readParameterFile

readParameterFile reads a parameter file and import the parameters into variable.

Vous suivez désormais cette soumission

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

Citation pour cette source

Carlos Galdino (2026). readParameterFile (https://fr.mathworks.com/matlabcentral/fileexchange/54063-readparameterfile), MATLAB Central File Exchange. Extrait(e) le .

Informations générales

Compatibilité avec les versions de MATLAB

  • Compatible avec toutes les versions

Plateformes compatibles

  • Windows
  • macOS
  • Linux
Version Publié le Notes de version Action
1.0.0.0