How can I subtract, add or multiply selected RMS simulation result signals and plot the result?
There are two possibilities to work with user defined variables in a dynamic simulation:
1. Using the option ’User Defined Signal’ included within the VisPlot. This allows calculation of additional results based on the arithmetic manipulation of one or more results. For more information refer to User Manual section 'Calculated Results'.
2. Using a separate DSL block. That would require you to create a DSL block, a frame, and the further definitions of object signals. Then the user defined signal will be defined as a signal in the DSL model, the simulation and plot has to be done as usual.
2. Postprocessing using a DPL script. This is the alternative option, attached you find a small example. The advantage is the simplicity, the disadvantage is that you have to run the script after each simulation. You might consider to put the execution of the transient simulation at the beginning of the DPL script.
The script takes the result file from the simulation, gets the values for each time step, multiplies these and stores the result in another result file. You can expand this scheme by multiplying values from different result files, or perform more complicated calculations. You may want to use IntMat (matrix) or IntVec (vector) objects for temporary storage of data in that case.
The function GetResData() without column index returns the time, otherwise a column-index [0..max] can be used. This is different from the column index that is used when exporting the contents of a result-file, where the first data-column has number 2 (the time-column has 1).
The Result file in the DPL script writes a line of data when WriteDraw() is called. It is set-up in such a way as to write the Result parameters of the DPL script (on the Advanced Options Page).