Adding Curves or Creating New Curves From Existing Data

You can add a curve from existing data without modifying the data. You can also create a curve from existing data by modifying the data using predefined operators to, for example, add the data of another curve.

Note: To add external curves, that is, existing curves from other tabs or curves saved in the database, see Adding External Curves

This task shows you how to:

Adding Curves From Existing Data

You can add a new curve from existing data without modifying the data.

Before you begin: Plot the execution results.
  1. Right-click a chart, then select Edit > Create Curve.
    The Create Curve dialog box appears.
  2. Select the Operator alternative if not selected.

    By default, this option is selected.

  3. From the list, select None.
  4. Click Select to insert Data 1.
    The Select curves dialog box appears, displaying the curves in the plot, and the time.

    You can select the curve from the Select curves dialog box. Click OK to validate.

    Tip: You can display other signals to select from; if you click a signal in the Variable Browser that signal is displayed in the Select curves dialog box.
  5. Click OK in the Create Curve dialog box to validate.
    The curve is created in the chart.
    Note: You can pause the pointer over a curve point to see its maximum, minimum and slope.

Create a New Curve from Existing Data, Optionally with Predefined Operators

You can create a new curve from existing data, optionally with predefined operators.

Before you begin: Plot the execution results.
  1. Right-click a chart, then select Edit > Create Curve.
    The Create Curve dialog box appears.
  2. Select the Operator alternative if not selected.

    By default, this option is selected.

  3. From the list, select the convenient operator.
  4. Click Select to insert Data 1.
    The Select curves dialog box appears, displaying the curves in the plot, and the time.

    You can select the curve from the Select curves dialog box. Click OK to validate.

    Tip: You can display other signals to select from; if you click a signal in the Variable Browser that signal is displayed in the Select curves dialog box.
    Note: For the None and Absolute operators, you can only select Data 1.
  5. To insert Data 2, repeat the previous step for Data 2.
  6. Click OK in the Create Curve dialog box to validate.
    The curve is created in the chart.
    Note: You can pause the pointer over a curve point to see its maximum, minimum and slope.

Create a New Curve Using General Expressions in a Dialog Box

You can create a new curve from existing data using general expressions.

Before you begin: Plot the execution results.
  1. Right-click a chart, then select Edit > Create Curve.
    The Create Curve dialog box appears.
  2. Select the General Expression alternative.
  3. Type and select signals to create an expression. The following steps 4-6 explain how to select a signal.
  4. Signals to select from different locations can be displayed the following ways:
    • From the plot, click the plot to display the corresponding signals in a Select signal dialog box.
    • From the Variable Browser, click a node to select from the signals corresponding to the leaves in that node. A corresponding Select signal dialog box is displayed.
  5. Select the signal you want to add in the expression.
  6. Click OK in the Select signal dialog box to add the signal to the expression and close the dialog box.
  7. You can continue to add signals as in step 4-6 above in the expression. You must also manually enter operators like +, -, sin, cos, to create the expression.
    An example selecting signals from a plot might be:
    1+abs(sin( .Plotter[1].Chart[1].'J1.phi')-sin( .Plotter[1].Chart[1].'J2.phi'))
  8. Click OK in the Create curve dialog box to create the corresponding curve and close the dialog box.
    The expression is computed, and if valid, a curve is created; otherwise an error message appears.

Create a New Curve Using General Expressions by Scripting

You can create a new curve from existing data using general expressions, by scripting.

The scenario below describes how to use the Modelica Scripting window to display a plot of signals from the model example Coupled Clutches, but scripts can also be saved and later executed by, for example, Modelica code.

In this example the Modelica Scripting window is used, but the Modelica Script Editor can also be used. For more information about scripting, see Dymola Behavior Modeling User's Guide: Performing a Virtual Execution: Scripting.

Before you begin: Simulation results must be present (the model must be simulated before any curves can be displayed). This corresponds to step 1–2 in the scenario below.
  1. From the Behavior Tools section of the action bar, click Coupled Clutches to open the model example Coupled Clutches.
  2. From the Behavior Authoring section, click Execute to simulate the model and create simulation results.
  3. From the Behavior Tools section, click Modelica Scripting .
    The Modelica Scripting window is displayed.
  4. Enter the following in the command input line of the Modelica Scripting window (the line in the lower part of the window): plotExpression(apply(J1.w+sin(J2.w)),true,"MyExpression"); and press Enter.
    One of the following is displayed:
    • If no plot is displayed, a new plot with the expression plotted is displayed.
    • If one or more plots exist, the latest/last plot is displaying the expression plotted (earlier signals in this plot are erased, due to (eraseOld=)true in the function call.)
  5. Optional: If you want to display all alternatives of the function call, enter document("plotExpression"); in the command line input of the Modelica Scripting window and press Enter.
    The documentation of the function is displayed.

    An example using more of the features would be:

    plotExpression(apply(CoupledClutches[end].J1.w+sin(CoupledClutches[end-1].J2.w)),true,"MyExpression2",-1);

    Here J1.w is taken from the last simulation (results file), while J2.w is taken from the second last simulation (results file). (Absolute pointing can be used as well, for example CoupledClutches[1].J3.phi.) The resulting curve is displayed in a new plot (-1). To display it in a specific plot, you can use the number of the plot, for example 2.