## Modelica_LinearSystems2.Utilities.Plot.Examples.Utilities

Utility functions (usually not of interest for the user)

### Package Content

Name | Description
--- | ---
dampedSine | Return a damped sine chracteristic

## Modelica_LinearSystems2.Utilities.Plot.Examples.Utilities.dampedSine

Return a damped sine chracteristic

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
Frequency | freqHz |  | Frequency of sine wave [Hz]
Damping | damping |  | Damping coefficient of sine wave [s-1]
Integer | nPeriod | 5 | Number of periods to show
Integer | nPoints | 500 | Number of points

### Outputs

Type | Name | Description
--- | --- | ---
Real | x[nPoints] |
Real | y[nPoints] |

### Modelica definition

    function dampedSine "Return a damped sine chracteristic"
       input Modelica.SIunits.Frequency freqHz "Frequency of sine wave";
       input Modelica.SIunits.Damping damping "Damping coefficient of sine wave";
       input Integer nPeriod=5 "Number of periods to show";
       input Integer nPoints(min=2)=500 "Number of points";
       output Real x[nPoints];
       output Real y[nPoints];
    protected
     Real xEnd = 1/freqHz*nPeriod;
    algorithm
       x :=0:xEnd/(nPoints - 1):xEnd;
       for i in 1:size(x,1) loop
          y[i] :=Modelica.Math.exp(-x[i]*damping)*
                 Modelica.Math.sin(2*Modelica.Constants.pi*freqHz*x[i]);
       end for;
    end dampedSine;