## Modelica_LinearSystems2.StateSpace.Plot

Functions to plot state space system responses

### Package Content

Name | Description
--- | ---
polesAndZeros | Plot poles (i.e. eigenvalues) and/or invariant zeros of a state space system
bodeSISO | Plot bode plot of the corresponding transfer function
bodeMIMO | Plot bode plot of all transfer functions, corresponding to the state space system
timeResponse | Plot the time response of the system. The response type is selectable
impulse | Impulse response plot
step | Step response plot
ramp | Ramp response plot
initialResponse | Initial condition response plot

## Modelica_LinearSystems2.StateSpace.Plot.polesAndZeros

Plot poles (i.e. eigenvalues) and/or invariant zeros of a state space system

### Information

#### Syntax

>     StateSpace.Plot.polesAndZeros(ss);
>        or
>     diagram = StateSpace.Plot.polesAndZeros(ss, poles=true, zeros=true, plot=true,
>                          defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramPolesAndZeros(),
>                          device=Modelica_LinearSystems2.Utilities.Plot.Records.Device());

#### Description

This function plots a pole-zero-map of the poles and transmission zeros of a state space system. The poles are the eigenvalues of the system matrix (eigenvalues(ss.A)). The Boolean inputs "poles" and "zeros" define what to plot. If Boolean input "plot = true", the pole-zero-map is plotted. If false, only the diagram is generated and returned as output argument. The records "defaultDiagram" and "device" allow to set various layout options and the size and location of the diagram on the screen.

#### Example

The example Modelica_LinearSystems2.Examples.StateSpace.plotPolesAndZeros is defined as

      Plot.polesAndZeros(ss = Modelica_LinearSystems2.StateSpace(
          A=[-3, 2,-3,  4, 5,6;
              0, 6, 7,  8, 9,4;
              0, 2, 3,  0,78,6;
              0, 1, 2,  2, 3,3;
              0,13,34,  0, 0,1;
              0, 0, 0,-17, 0,0],
          B=[1,0;
             0,1;
             1,0;
             0,1;
             1,0;
             0,1],
          C=[0,0,1,0,1,0;
             0,1,0,0,1,1],
          D=[0,0;
             0,0]));

and results in

Extends from Modelica_LinearSystems2.Internal.PartialPlotFunction (Interface of a plot function).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
StateSpace | ss |  | Linear system in state space form
Boolean | poles | true | = true, to plot the poles (i.e. the eigenvalues) of ss
Boolean | zeros | true | = true, to plot the (invariant) zeros of ss
Diagram | defaultDiagram | Modelica_LinearSystems2.Inte... | Default diagram layout
Device | device | Modelica_LinearSystems2.Util... | Properties of device where figure is shown

### Modelica definition

    encapsulated function polesAndZeros
      "Plot poles (i.e. eigenvalues) and/or invariant zeros of a state space system"
      import Modelica;
      import Modelica_LinearSystems2;
      import Modelica_LinearSystems2.StateSpace;
      import Modelica_LinearSystems2.Math.Complex;
      import Modelica_LinearSystems2.Utilities.Plot;

      input StateSpace ss "Linear system in state space form";
      input Boolean poles=true
        "= true, to plot the poles (i.e. the eigenvalues) of ss";
      input Boolean zeros=true "= true, to plot the (invariant) zeros of ss ";

      extends Modelica_LinearSystems2.Internal.PartialPlotFunction(
         defaultDiagram = Modelica_LinearSystems2.Internal.DefaultDiagramPolesAndZeros());

    protected
      Integer nx=size(ss.A, 1);
      Real eval[nx,2];
      Real invZerosRe[:];
      Real invZerosIm[:];
      Complex invZeros[:];
      Plot.Records.Curve curves[2];
      Integer i;
      Plot.Records.Diagram diagram2;
    algorithm
      // Determine eigen values
      if poles then
        eval := Modelica.Math.Matrices.eigenValues(ss.A);
      end if;

      if zeros then
        invZeros := StateSpace.Analysis.invariantZeros(ss);
        invZerosRe := fill(0,size(invZeros,1));
        invZerosIm := fill(0,size(invZeros,1));
        for i in 1:size(invZeros, 1) loop
          invZerosRe[i] := invZeros[i].re;
          invZerosIm[i] := invZeros[i].im;
        end for;
      end if;

      i :=0;
      if poles then
         i :=i + 1;
         curves[i] :=Plot.Records.Curve(
                            x=eval[:, 1],
                            y=eval[:, 2],
                            legend="poles",
                            autoLine=false,
                            linePattern=Plot.Types.LinePattern.None,
                            lineSymbol=Plot.Types.PointSymbol.Cross);
      end if;

      if zeros then
         i :=i + 1;
         curves[i] :=Plot.Records.Curve(
                            x=invZerosRe,
                            y=invZerosIm,
                            legend="zeros",
                            autoLine=false,
                            linePattern=Plot.Types.LinePattern.None,
                            lineSymbol=Plot.Types.PointSymbol.Circle);
      end if;

         diagram2 :=defaultDiagram;
         diagram2.curve :=curves[1:i];
         Plot.diagram(diagram2,device);

    end polesAndZeros;

## Modelica_LinearSystems2.StateSpace.Plot.bodeSISO

Plot bode plot of the corresponding transfer function

### Information

#### Syntax

>     StateSpace.Plot.plotBodeSISO(ss)
>        or
>     StateSpace.Plot.plotBodeSISO(ss, iu, iy, nPoints, autoRange, f_min, f_max, magnitude=true, phase=true, defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramBodePlot(), device=Modelica_LinearSystems2.Utilities.Plot.Records.Device() )

#### Description

Plots the bode-diagram of a transfer function.

#### Description

Function plotBodeSISO plots a bode-diagram of the transfer function corresponding to the behavior of the state space system from iu'th element of the input vector u to the iy'th element of the output vector y.

#### Example

>        Modelica_LinearSystems2.StateSpace ss=Modelica_LinearSystems2.StateSpace(
>           A=[-1.0,0.0,0.0; 0.0,-2.0,0.0; 0.0,0.0,-3.0],
>           B=[0.0,1.0; 1.0,1.0; -1.0,0.0],
>           C=[0.0,1.0,1.0; 1.0,1.0,1.0],
>           D=[1.0,0.0; 0.0,1.0])

>        Integer iu=1;
>        Integer iy=1;

>     algorithm
>        Modelica_LinearSystems2.StateSpace.Plot.plotBodeSISO(ss, iu, iy)
>     //  gives:

Extends from Modelica_LinearSystems2.Internal.PartialPlotFunction (Interface of a plot function).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
StateSpace | ss |  | state space system
Integer | iu | 1 | index of input
Integer | iy | 1 | index of output
Integer | nPoints | 200 | Number of points
Boolean | autoRange | true | = true, if abszissa range is automatically determined
Frequency | f_min | 0.1 | Minimum frequency value, if autoRange = false [Hz]
Frequency | f_max | 10 | Maximum frequency value, if autoRange = false [Hz]
Boolean | magnitude | true | = true, to plot the magnitude of tf
Boolean | phase | true | = true, to plot the pase of tf
Diagram | defaultDiagram | Modelica_LinearSystems2.Inte... | Default diagram layout
Device | device | Modelica_LinearSystems2.Util... | Properties of device where figure is shown

### Modelica definition

    encapsulated function bodeSISO
      "Plot bode plot of the corresponding transfer function"
      import Modelica;
      import Modelica_LinearSystems2;
      import Modelica_LinearSystems2.StateSpace;
      import Modelica_LinearSystems2.ZerosAndPoles;

      input StateSpace ss "state space system";
      input Integer iu=1 "index of input";
      input Integer iy=1 "index of output";
      input Integer nPoints(min=2) = 200 "Number of points";
      input Boolean autoRange=true
        "= true, if abszissa range is automatically determined";
      input Modelica.SIunits.Frequency f_min=0.1
        "Minimum frequency value, if autoRange = false";
      input Modelica.SIunits.Frequency f_max=10
        "Maximum frequency value, if autoRange = false";

      input Boolean magnitude=true "= true, to plot the magnitude of tf";
      input Boolean phase=true "= true, to plot the pase of tf";

      extends Modelica_LinearSystems2.Internal.PartialPlotFunction(defaultDiagram=
            Modelica_LinearSystems2.Internal.DefaultDiagramBodePlot());

    protected
      ZerosAndPoles zp "ZP-Transfer functions to be plotted";
      StateSpace ss_siso(
        redeclare Real A[size(ss.A, 1),size(ss.A, 2)],
        redeclare Real B[size(ss.B, 1),1],
        redeclare Real C[1,size(ss.C, 2)],
        redeclare Real D[1,1]);

    algorithm
      assert(iu <= size(ss.B, 2) and iu > 0, "index for input is " + String(iu) + " which is not in [1, "
         + String(size(ss.B, 2)) + "].");
      assert(iy <= size(ss.C, 1) and iy > 0, "index for output is " + String(iy) + " which is not in [1, "
         + String(size(ss.C, 1)) + "].");
      ss_siso := StateSpace(
        A=ss.A,
        B=matrix(ss.B[:, iu]),
        C=transpose(matrix(ss.C[iy, :])),
        D=matrix(ss.D[iy, iu]));
      zp := StateSpace.Conversion.toZerosAndPoles(ss_siso);

      ZerosAndPoles.Plot.bode(
        zp,
        nPoints,
        autoRange,
        f_min,
        f_max,
        magnitude,
        phase,
        defaultDiagram=defaultDiagram,
        device=device);

    end bodeSISO;

## Modelica_LinearSystems2.StateSpace.Plot.bodeMIMO

Plot bode plot of all transfer functions, corresponding to the state space system

### Information

#### Syntax

>     StateSpace.Plot.plotBodeMIMO(ss)
>        or
>     StateSpace.Plot.plotBodeMIMO(ss, nPoints, autoRange, f_min, f_max, magnitude=true, phase=true, defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramBodePlot(), device=Modelica_LinearSystems2.Utilities.Plot.Records.Device() )

#### Example

>        Modelica_LinearSystems2.StateSpace ss=Modelica_LinearSystems2.StateSpace(
>           A=[-1.0,0.0,0.0; 0.0,-2.0,0.0; 0.0,0.0,-3.0],
>           B=[0.0,1.0; 1.0,1.0; -1.0,0.0],
>           C=[0.0,1.0,1.0],
>           D=[1.0,0.0])

>     algorithm
>        Modelica_LinearSystems2.StateSpace.Plot.plotBodeMIMO(ss)
>     //  gives:

Extends from Modelica_LinearSystems2.Internal.PartialPlotFunction (Interface of a plot function).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
StateSpace | ss |  |
Integer | nPoints | 200 | Number of points
Boolean | autoRange[:, :] | fill(true, size(ss.C, 1), si... | = true, if abszissa range is automatically determined
Frequency | f_min[:, :] | fill(0.1, size(ss.C, 1), siz... | Minimum frequency value, if autoRange = false [Hz]
Frequency | f_max[:, :] | fill(10, size(ss.C, 1), size... | Maximum frequency value, if autoRange = false [Hz]
Boolean | magnitude | true | = true, to plot the magnitude of tf
Boolean | phase | true | = true, to plot the pase of tf
Diagram | defaultDiagram | Modelica_LinearSystems2.Inte... | Default diagram layout
Device | device | Modelica_LinearSystems2.Util... | Properties of device where figure is shown

### Modelica definition

    encapsulated function bodeMIMO
      "Plot bode plot of all transfer functions, corresponding to the state space system"

      import Modelica;
      import Modelica_LinearSystems2;
      import Modelica_LinearSystems2.StateSpace;
      import Modelica_LinearSystems2.TransferFunction;
      import Modelica_LinearSystems2.Utilities.Plot;

      input StateSpace ss;
      input Integer nPoints(min=2) = 200 "Number of points";
      input Boolean autoRange[:,:]=fill(
          true,
          size(ss.C, 1),
          size(ss.B, 2)) "= true, if abszissa range is automatically determined";
      input Modelica.SIunits.Frequency f_min[:,:]=fill(
          0.1,
          size(ss.C, 1),
          size(ss.B, 2)) "Minimum frequency value, if autoRange = false";
      input Modelica.SIunits.Frequency f_max[:,:]=fill(
          10,
          size(ss.C, 1),
          size(ss.B, 2)) "Maximum frequency value, if autoRange = false";
      input Boolean magnitude=true "= true, to plot the magnitude of tf";
      input Boolean phase=true "= true, to plot the pase of tf";

      extends Modelica_LinearSystems2.Internal.PartialPlotFunction(defaultDiagram=
            Modelica_LinearSystems2.Internal.DefaultDiagramBodePlot());

    protected
      TransferFunction tf[size(ss.C, 1),size(ss.B, 2)]
        "Transfer functions to be plotted";
      Plot.Records.Diagram diagram2=defaultDiagram;
      String yNames[size(ss.C, 1)];
      String uNames[size(ss.B, 2)];

    algorithm
     // generate headings
      for i1 in 1:size(ss.B, 2) loop
        uNames[i1] := if ss.uNames[i1] == "" then "u" + String(i1) else ss.uNames[i1];
      end for;
      for i1 in 1:size(ss.C, 1) loop
        yNames[i1] := if ss.yNames[i1] == "" then "y" + String(i1) else ss.yNames[i1];
      end for;

      tf := StateSpace.Conversion.toTransferFunctionMIMO(ss);

      for i1 in 1:size(ss.C, 1) loop
        for i2 in 1:size(ss.B, 2) loop
          diagram2.heading := defaultDiagram.heading +"  "+ uNames[i2] + " -> " + yNames[i1];
          TransferFunction.Plot.bode(
            tf[i1, i2],
            nPoints,
            autoRange[i1, i2],
            f_min[i1, i2],
            f_max[i1, i2],
            magnitude,
            phase,
            defaultDiagram=diagram2,
            device=device);
        end for;
      end for;

    end bodeMIMO;

## Modelica_LinearSystems2.StateSpace.Plot.timeResponse

Plot the time response of the system. The response type is selectable

### Information

Syntax

>     StateSpace.Plot.timeResponse(ss);
>     or
>     StateSpace.Plot.timeResponse(ss, dt, tSpan,response, x0, defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramTimeResponse(),
>     device=Modelica_LinearSystems2.Utilities.Plot.Records.Device())

#### Description

Function timeResponse plots the time response of a state space system. The character of the time response if defined by the input `response`, i.e. Impulse, Step, Ramp, or Initial. See also plotImpulse, step, ramp, and initial.

#### Example

>     Modelica_LinearSystems2.StateSpace ss=Modelica_LinearSystems2.StateSpace(
>     A=[-1.0,0.0,0.0; 0.0,-2.0,3.0; 0.0,-2.0,-3.0],
>     B=[1.0; 1.0; 0.0],
>     C=[0.0,1.0,1.0],
>     D=[0.0])

>     Types.TimeResponse response=Modelica_LinearSystems2.Types.TimeResponse.Step;

>     algorithm
>     Modelica_LinearSystems2.StateSpace.Plot.timeResponse(ss, response=response)
>     // gives:

Extends from Modelica_LinearSystems2.Internal.PartialPlotFunctionMIMO (Interface of a plot function for MIMO systems).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
StateSpace | ss |  |
Real | dt | 0 | Sample time [s]
Real | tSpan | 0 | Simulation time span [s]
TimeResponse | response | Modelica_LinearSystems2.Type... |
Real | x0[size(ss.A, 1)] | zeros(size(ss.A, 1)) | Initial state vector
Boolean | subPlots | true | true if all subsystem time responses are plotted in one window with subplots
Diagram | defaultDiagram | Modelica_LinearSystems2.Inte... | Default diagram layout
Device | device | Modelica_LinearSystems2.Util... | Properties of device where figure is shown

### Modelica definition

    encapsulated function timeResponse
      "Plot the time response of the system. The response type is selectable"

      import Modelica;
      import Modelica_LinearSystems2;
      import Modelica_LinearSystems2.StateSpace;
      import Modelica_LinearSystems2.Types.TimeResponse;

      import Modelica_LinearSystems2.Utilities.Plot;

      input StateSpace ss;
      input Real dt=0 "Sample time [s]";
      input Real tSpan=0 "Simulation time span [s]";

      input Modelica_LinearSystems2.Types.TimeResponse response=
          Modelica_LinearSystems2.Types.TimeResponse.Step;

      input Real x0[size(ss.A, 1)]=zeros(size(ss.A, 1)) "Initial state vector";

      input Boolean subPlots=true
        "true if all subsystem time responses are plotted in one window with subplots";

      extends Modelica_LinearSystems2.Internal.PartialPlotFunctionMIMO(defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramTimeResponse(
            heading="Time response"));

    protected
      Plot.Records.Curve curve;
      Integer i1;
      Integer i2;
      Plot.Records.Diagram diagram2[size(ss.C, 1)];

      Real y[:,size(ss.C, 1),if response == TimeResponse.Initial then 1 else size(ss.B,2)]
        "Output response: (number of samples) x (number of outputs) x (number of inputs)";
      Real t[:] "Time vector: (number of samples)";
      Real x[:,size(ss.A, 1),if response == TimeResponse.Initial then 1 else size(ss.B,2)]
        "State trajectories: (number of samples) x (number of states) x (number of inputs)";
      String yNames[size(ss.C, 1)];
      String uNames[size(ss.B, 2)];
      Integer loops=if response == TimeResponse.Initial then 1 else size(ss.B,2);

    algorithm
      (y,t,x) := Modelica_LinearSystems2.StateSpace.Analysis.timeResponse(
        sc=ss,
        dt=dt,
        tSpan=tSpan,
        response=response,
        x0=x0);

    // generate headings
      for i1 in 1:size(ss.B, 2) loop
        uNames[i1] := if ss.uNames[i1] == "" then "u" + String(i1) else ss.uNames[
          i1];
      end for;
      for i1 in 1:size(ss.C, 1) loop
        yNames[i1] := if ss.yNames[i1] == "" then "y" + String(i1) else ss.yNames[
          i1];
      end for;

      for i2 in 1:loops loop
        for i1 in 1:size(ss.C, 1) loop
          curve := Plot.Records.Curve(
            x=t,
            y=y[:, i1, i2],
            autoLine=true);

          diagram2[i1] := defaultDiagram;
          diagram2[i1].curve := {curve};
          diagram2[i1].heading := if response == TimeResponse.Initial then defaultDiagram.heading +" "+ yNames[i1] else defaultDiagram.heading + "  " + uNames[i2] + " -> " + yNames[i1];
          diagram2[i1].yLabel := yNames[i1];

        end for;

        if subPlots then
          Plot.diagramVector(diagram2, device);
        else
          for i1 in 1:size(ss.C, 1) loop
            Plot.diagram(diagram2[i1], device);
          end for;
        end if;
      end for;

    end timeResponse;

## Modelica_LinearSystems2.StateSpace.Plot.impulse

Impulse response plot

### Information

Syntax

>     StateSpace.Plot.impulse(ss);
>     or
>     StateSpace.Plot.impulse(ss, dt, tSpan, x0, defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramTimeResponse(),
>     device=Modelica_LinearSystems2.Utilities.Plot.Records.Device())

#### Description

Function plotImpulse plots the impulse responses of a state space system for each system corresponding to the transition matrix. It is based on timeResponse. See also step, ramp, and initial.

#### Example

>     Modelica_LinearSystems2.StateSpace ss=Modelica_LinearSystems2.StateSpace(
>     A=[-1.0,0.0,0.0; 0.0,-2.0,3.0; 0.0,-2.0,-3.0],
>     B=[1.0; 1.0; 0.0],
>     C=[0.0,1.0,1.0],
>     D=[0.0])

>     algorithm
>     Modelica_LinearSystems2.StateSpace.Plot.impulse(ss)
>     // gives:

Extends from Modelica_LinearSystems2.Internal.PartialPlotFunctionMIMO (Interface of a plot function for MIMO systems).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
StateSpace | ss |  |
Real | dt | 0 | Sample time [s]
Real | tSpan | 0 | Simulation time span [s]
Real | x0[size(ss.A, 1)] | zeros(size(ss.A, 1)) | Initial state vector
Boolean | subPlots | true | true if all subsystem time responses are plotted in one window with subplots
Diagram | defaultDiagram | Modelica_LinearSystems2.Inte... | Default diagram layout
Device | device | Modelica_LinearSystems2.Util... | Properties of device where figure is shown

### Modelica definition

    encapsulated function impulse "Impulse response plot"

      import Modelica;
      import Modelica_LinearSystems2;
      import Modelica_LinearSystems2.StateSpace;
      import Modelica_LinearSystems2.Types.TimeResponse;

      import Modelica_LinearSystems2.Utilities.Plot;

      input StateSpace ss;
      input Real dt=0 "Sample time [s]";
      input Real tSpan=0 "Simulation time span [s]";
      input Real x0[size(ss.A, 1)]=zeros(size(ss.A, 1)) "Initial state vector";

      input Boolean subPlots=true
        "true if all subsystem time responses are plotted in one window with subplots";

      extends Modelica_LinearSystems2.Internal.PartialPlotFunctionMIMO(defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramTimeResponse(heading="Impulse response"));

    protected
      input Modelica_LinearSystems2.Types.TimeResponse response=Modelica_LinearSystems2.Types.TimeResponse.Impulse
        "type of time response";
    algorithm

      Modelica_LinearSystems2.StateSpace.Plot.timeResponse(
        ss=ss,
        dt=dt,
        tSpan=tSpan,
        response=response,
        x0=x0,
        defaultDiagram=defaultDiagram,
        device=device);

    end impulse;

## Modelica_LinearSystems2.StateSpace.Plot.step

Step response plot

### Information

Syntax

>     StateSpace.Plot.step(ss);
>     or
>     StateSpace.Plot.step(ss, dt, tSpan, x0, defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramTimeResponse(),
>     device=Modelica_LinearSystems2.Utilities.Plot.Records.Device())

#### Description

Function step plots the step responses of a state space system for each system corresponding to the transition matrix. It is based on timeResponse. See also impulse, ramp, and initial.

#### Example

>     Modelica_LinearSystems2.StateSpace ss=Modelica_LinearSystems2.StateSpace(
>     A=[-1.0,0.0,0.0; 0.0,-2.0,3.0; 0.0,-2.0,-3.0],
>     B=[1.0; 1.0; 0.0],
>     C=[0.0,1.0,1.0],
>     D=[0.0])

>     algorithm
>     Modelica_LinearSystems2.StateSpace.Plot.step(ss, tSpan=3)
>     // gives:

Extends from Modelica_LinearSystems2.Internal.PartialPlotFunctionMIMO (Interface of a plot function for MIMO systems).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
StateSpace | ss |  |
Real | dt | 0 | Sample time [s]
Real | tSpan | 0 | Simulation time span [s]
Real | x0[size(ss.A, 1)] | zeros(size(ss.A, 1)) | Initial state vector
Boolean | subPlots | true | true if all subsystem time responses are plotted in one window with subplots
Diagram | defaultDiagram | Modelica_LinearSystems2.Inte... | Default diagram layout
Device | device | Modelica_LinearSystems2.Util... | Properties of device where figure is shown
TimeResponse | response | Modelica_LinearSystems2.Type... | type of time response

### Modelica definition

    encapsulated function step "Step response plot"

      import Modelica;
      import Modelica_LinearSystems2;
      import Modelica_LinearSystems2.StateSpace;
      import Modelica_LinearSystems2.Types.TimeResponse;

      import Modelica_LinearSystems2.Utilities.Plot;

      input StateSpace ss;
      input Real dt=0 "Sample time [s]";
      input Real tSpan=0 "Simulation time span [s]";
      input Real x0[size(ss.A, 1)]=zeros(size(ss.A, 1)) "Initial state vector";

      input Boolean subPlots=true
        "true if all subsystem time responses are plotted in one window with subplots";

      extends Modelica_LinearSystems2.Internal.PartialPlotFunctionMIMO(defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramTimeResponse(heading="Step response"));

      input Modelica_LinearSystems2.Types.TimeResponse response=
          Modelica_LinearSystems2.Types.TimeResponse.Step "type of time response";

    algorithm
      Modelica_LinearSystems2.StateSpace.Plot.timeResponse(
        ss=ss,
        dt=dt,
        tSpan=tSpan,
        response=response,
        x0=x0,
        defaultDiagram=defaultDiagram,
        device=device);

    end step;

## Modelica_LinearSystems2.StateSpace.Plot.ramp

Ramp response plot

### Information

Syntax

>     StateSpace.Plot.ramp(ss);
>     or
>     StateSpace.Plot.ramp(ss, dt, tSpan, x0, defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramTimeResponse(),
>     device=Modelica_LinearSystems2.Utilities.Plot.Records.Device())

#### Description

Function ramp plots the ramp responses of a state space system for each system corresponding to the transition matrix. It is based on timeResponse. See also impulse, step, and initial.

#### Example

>     Modelica_LinearSystems2.StateSpace ss=Modelica_LinearSystems2.StateSpace(
>     A=[-1.0,0.0,0.0; 0.0,-2.0,3.0; 0.0,-2.0,-3.0],
>     B=[1.0; 1.0; 0.0],
>     C=[1.0,1.0,1.0],
>     D=[0.0])

>     algorithm
>     Modelica_LinearSystems2.StateSpace.Plot.ramp(ss)
>     // gives:

Extends from Modelica_LinearSystems2.Internal.PartialPlotFunctionMIMO (Interface of a plot function for MIMO systems).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
StateSpace | ss |  |
Real | dt | 0 | Sample time [s]
Real | tSpan | 0 | Simulation time span [s]
Real | x0[size(ss.A, 1)] | zeros(size(ss.A, 1)) | Initial state vector
Boolean | subPlots | true | true if all subsystem time responses are plotted in one window with subplots
Diagram | defaultDiagram | Modelica_LinearSystems2.Inte... | Default diagram layout
Device | device | Modelica_LinearSystems2.Util... | Properties of device where figure is shown
TimeResponse | response | Modelica_LinearSystems2.Type... | type of time response

### Modelica definition

    encapsulated function ramp "Ramp response plot"

      import Modelica;
      import Modelica_LinearSystems2;
      import Modelica_LinearSystems2.StateSpace;
      import Modelica_LinearSystems2.Types.TimeResponse;

      import Modelica_LinearSystems2.Utilities.Plot;

    input StateSpace ss;
    input Real dt=0 "Sample time [s]";
    input Real tSpan=0 "Simulation time span [s]";
    input Real x0[size(ss.A, 1)]=zeros(size(ss.A, 1)) "Initial state vector";

    input Boolean subPlots=true
        "true if all subsystem time responses are plotted in one window with subplots";

    extends Modelica_LinearSystems2.Internal.PartialPlotFunctionMIMO(defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramTimeResponse(
          heading="Ramp response"));

    input Modelica_LinearSystems2.Types.TimeResponse response=
        Modelica_LinearSystems2.Types.TimeResponse.Ramp "type of time response";

    algorithm
    Modelica_LinearSystems2.StateSpace.Plot.timeResponse(
          ss=ss,
          dt=dt,
          tSpan=tSpan,
          response=response,
          x0=x0,
          defaultDiagram=defaultDiagram,
          device=device);

    end ramp;

## Modelica_LinearSystems2.StateSpace.Plot.initialResponse

Initial condition response plot

### Information

Syntax

>     StateSpace.Plot.initial(ss);
>     or
>     StateSpace.Plot.initial(ss, dt, tSpan, x0, defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramTimeResponse(),
>     device=Modelica_LinearSystems2.Utilities.Plot.Records.Device())

#### Description

Function initial plots the initial responses of a state space system for the initial state vector x0 for each system corresponding to the transition matrix. It is based on timeResponse. See also impulse, step, and ramp.

#### Example

>     Modelica_LinearSystems2.StateSpace ss=Modelica_LinearSystems2.StateSpace(
>     A=[-1.0,0.0,0.0; 0.0,-2.0,3.0; 0.0,-2.0,-3.0],
>     B=[1.0; 1.0; 0.0],
>     C=[0.0,1.0,1.0],
>     D=[0.0])

>     Real x0={1,0.5,0.5};

>     algorithm
>     Modelica_LinearSystems2.StateSpace.Plot.initial(ss, x0=x0)
>     // gives:

Extends from Modelica_LinearSystems2.Internal.PartialPlotFunctionMIMO (Interface of a plot function for MIMO systems).

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
StateSpace | ss |  |
Real | dt | 0 | Sample time [s]
Real | tSpan | 0 | Simulation time span [s]
Real | x0[size(ss.A, 1)] | zeros(size(ss.A, 1)) | Initial state vector
Boolean | subPlots | true | true if all subsystem time responses are plotted in one window with subplots
Diagram | defaultDiagram | Modelica_LinearSystems2.Inte... | Default diagram layout
Device | device | Modelica_LinearSystems2.Util... | Properties of device where figure is shown
TimeResponse | response | Modelica_LinearSystems2.Type... | type of time response

### Modelica definition

    encapsulated function initialResponse
      "Initial condition response plot"
      import Modelica;
      import Modelica_LinearSystems2;
      import Modelica_LinearSystems2.StateSpace;
      import Modelica_LinearSystems2.Types.TimeResponse;

      import Modelica_LinearSystems2.Utilities.Plot;

      input StateSpace ss;
      input Real dt=0 "Sample time [s]";
      input Real tSpan=0 "Simulation time span [s]";
      input Real x0[size(ss.A, 1)]=zeros(size(ss.A, 1)) "Initial state vector";

      input Boolean subPlots=true
        "true if all subsystem time responses are plotted in one window with subplots";

      extends Modelica_LinearSystems2.Internal.PartialPlotFunctionMIMO(defaultDiagram=Modelica_LinearSystems2.Internal.DefaultDiagramTimeResponse(
            heading="Initial response"));

      input Modelica_LinearSystems2.Types.TimeResponse response=
          Modelica_LinearSystems2.Types.TimeResponse.Initial
        "type of time response";
    algorithm

      Modelica_LinearSystems2.StateSpace.Plot.timeResponse(
        ss=ss,
        dt=dt,
        tSpan=tSpan,
        response=response,
        x0=x0,
        defaultDiagram=defaultDiagram,
        device=device);

    end initialResponse;