.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" annotation(
    Dialog(loadSelector(filter = "m-file (*.m)", caption = "Open m-file for reading")));
  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-11-20T19:25:51Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos