Plotting general expressions

Dymola 2013 FD01 has the ability to create and plot a general expression through the context menu of a signal in a plot window.

1. Right-click on a plot window and select Plot Expression (you can also go to the Plot menu in the Dymola toolbar and then click on Plot Expression or simply click on the corresponding icon Plot expression toolbar icon).

Figure 1. Selection of Plot Expression from a plot window

Figure 1. Selection of Plot Expression from a plot window

2. A window will pop up on the screen, consisting of 2 fields:

  • Expression => write here the expression to be plotted.
  • Legend => the default one is the expression set, although it can be modified.
Dialog box for Plot Expression

Figure 2. Dialog box for Plot Expression

3. The expression set is parsed. If it is correct, it will be plotted after pressing OK.

Advanced notes:

When a dialog window pops, it includes the corresponding plotted signal. If the function is not invoked on a signal, the dialog box will not include any signal in it, as it can be seen in the figure below:

Dialog box for Plot Expression invoked without signal

Figure 3. Dialog box for Plot Expression invoked without signal

The actual expression in the dialog box can be created by a combination of manual editing and selecting other signals from the variable browser. To do this, simply click on the variable name in the variable browser and it will automatically appear in the window Expression. It is also possible to combine signals from different result files: the name of the variable will go with the result file identifiers end and end-1 for the latest and the second latest results (for the rest of the cases, the absolute sequence number of the result is attached).

When an expression has already been set and plotted, it can be modified. Right-click on the expression signal and select Edit Expression: the old dialog box will pop up and you will be able to edit it.

Another way of setting the expression is through the command window function plotExpression:

Inputs and outputs of the function plotExpression

Figure 4. Inputs and outputs of the function plotExpression

Example:

A simple test case is proposed to practise with this new feature. Follow the steps indicated next:

1. Go, for example, to Modelica.Mechanics.MultiBody.Examples.Loops.Fourbar1 and run it.

2. Plot these angular variables: j1.phi, j3.phi, j4.phi, j5.phi, rev.phi and rev1.phi.

3. Add a new subplot window where to represent the expression.

4. Click on Plot Expression and fill in the fields of the dialog box with the following:

  • Expression = Fourbar1[end].j1.phi + Fourbar1[end].j3.phi + Fourbar1[end].j4.phi + Fourbar1[end].j5.phi + Fourbar1[end].rev.phi + Fourbar1[end].rev1.phi
  • Legend: by default, it would be set to the same as Expression. Delete it and type “Sum of angles” (inverted commas not included in the name).
Plot window with the variables indicated

Figure 5. Plot window with the variables indicated

Plot Expression dialog box

Figure 6. Plot Expression dialog box

5. Right-click on the new signal and select Edit Expression. Use these new settings:

  • Expression = Fourbar1[end].j1.phi + Fourbar1[end].j3.phi + Fourbar1[end].j4.phi + Fourbar1[end].j5.phi – Fourbar1[end].rev.phi – Fourbar1[end].rev1.phi
  • Legend: delete “Sum of angles” and write “Weighted sum of angles”.
Edit Expression selection

Figure 7. Edit Expression selection

Plot view of edited expression

Figure 8.Plot view of edited expression

 

CONTACT US

Got a question? Just fill in this form and send it to us and we'll get back to you shortly.

Sending

© Copyright 2010-2024 Claytex Services Ltd All Rights Reserved

Log in with your credentials

Forgot your details?