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:
- It opens file "fileName" and reads the lines of the file.
- If a line starts with "% " or "// " or " ", it is skipped.
- 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.
- The result of the expression evaluation is returned as the value of the parameter "name".
Inputs
| Type | Name | Default | Description |
|---|---|---|---|
| String | fileName | Name of file | |
| String | name | Name of parameter | |
| Boolean | cache | false | Read file before compiling, if true |
Outputs
| Type | Name | Default | Description |
|---|---|---|---|
| Real | result | Actual value of parameter on file |