functionreadReal_m

Read the value of a Real parameter from m-file

Extends from Modelica.Icons.Function (Icon for functions).

Information

Syntax

result = readReal_m(fileName, name);

Description

This function demonstrates how a function can be implemented that reads the value of a parameter from a Matlab script-file. The idea is to keep parameters in Modelica and in Matlab/Simulink up to date. The function performs the following actions:

  1. It opens file "fileName" and reads the lines of the file.
  2. If a line starts with "% " or "// " or " ", it is skipped.
  3. If a line starts with "name = expression" and the "name" in this line is identical to the second argument "name" of the function call, the expression calculator is used to evaluate the expression after the "=" character. The expression has to be terminated with a ";". After the ";" a comment can follow.
  4. The result of the expression evaluation is returned as the value of the parameter "name".

Inputs

TypeNameDefaultDescription
StringfileNameName of file
StringnameName of parameter
BooleancachefalseRead file before compiling, if true

Outputs

TypeNameDefaultDescription
RealresultActual value of parameter on file