.KeyWordIO.readReal_m

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".

Interface

function readReal_m
  extends Modelica.Icons.Function;
  import Modelica.Utilities.*;
  input String fileName "Name of file";
  input String name "Name of parameter";
  input Boolean cache = false "Read file before compiling, if true";
  output Real result "Actual value of parameter on file";
end readReal_m;

Generated at 2024-04-28T18:16:21Z by OpenModelicaOpenModelica 1.22.3 using GenerateDoc.mos