## Modelica_LinearSystems2.Internal.Streams

### Package Content

Name | Description
--- | ---
AnalyseOptions | Defines the characteristics of the eigenvalues to be print or to be plot
ReadMatrixA | Read the state matrix of a state space system
ReadMatrixA2 | Read the state matrix of a state space system
ReadMatrixB | Read the input matrix of a state space system
ReadMatrixB2 | Read the input matrix of a state space system
ReadMatrixC | Read the output matrix of a state space system
ReadMatrixC2 | Read the output matrix of a state space system
ReadMatrixD | Read the feed forward matrix of a state space system
ReadMatrixD2 | Read the feed forward matrix of a state space system
readMatrixInternal |
readMatrixOnFileSize |
ReadSystemDimension | Read the order nx of state matrix and the numbers nu and ny of inputs and outputs
ReadSystemDimension2 | Read the order nx of state matrix and the numbers nu and ny of inputs and outputs
stateSpaceString_html |

## Modelica_LinearSystems2.Internal.Streams.AnalyseOptions

Defines the characteristics of the eigenvalues to be print or to be plot

### Information

Extends from Modelica.Icons.Record (Icon for a record).

### Modelica definition

    record AnalyseOptions
      "Defines the characteristics of the eigenvalues to be print or to be plot"
       extends Modelica.Icons.Record;
       Boolean plotEigenValues = true;
       Boolean plotInvariantZeros = true;
       String headingEigenValues = "Eigen values and invariant zeros";
       Boolean printEigenValues = true;
       Boolean printInvariantZeros = true;
       Boolean printControllability = true;
       Boolean printObservability = true;
       Boolean plotStepResponse = true "only for SISO system";
       String headingStepResponse = "Step response";
       Boolean plotFrequencyResponse = true "only for SISO system";
       String headingFrequencyResponse = "Frequency response";

    end AnalyseOptions;

## Modelica_LinearSystems2.Internal.Streams.ReadMatrixA

Read the state matrix of a state space system

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
String | fileName | DataDir + "abcd.mat" |
String | matrixName | "ABCD" | Name of the generalized state space system matrix

### Outputs

Type | Name | Description
--- | --- | ---
Real | A[nx, nx] |

### Modelica definition

    function ReadMatrixA "Read the state matrix of a state space system"
      input String fileName=DataDir + "abcd.mat";
      input String matrixName="ABCD"
        "Name of the generalized state space system matrix";

    protected
      Real sizeA[1,1]=Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          "nx",
          1,
          1);
      Integer ABCDsizes[2]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixOnFileSize(fileName,
          matrixName);
      Integer nx=integer(sizeA[1, 1]);

      Integer nu=ABCDsizes[2] - nx;
      Integer ny=ABCDsizes[1] - nx;
      Real ABCD[nx + ny,nx + nu]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          matrixName,
          nx + ny,
          nx + nu);

    public
      output Real A[nx,nx]=ABCD[1:nx, 1:nx];
    algorithm

    end ReadMatrixA;

## Modelica_LinearSystems2.Internal.Streams.ReadMatrixA2

Read the state matrix of a state space system

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
String | fileName | DataDir + "abcd.mat" |
String | matrixName | "ABCD" | Name of the generalized state space system matrix
Integer | nx |  | System order

### Outputs

Type | Name | Description
--- | --- | ---
Real | A[nx, nx] |

### Modelica definition

    function ReadMatrixA2 "Read the state matrix of a state space system"
      input String fileName=DataDir + "abcd.mat";
      input String matrixName="ABCD"
        "Name of the generalized state space system matrix";
      input Integer nx "System order";

    protected
      Integer ABCDsizes[2]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixOnFileSize(fileName,
          matrixName);

      Integer nu=ABCDsizes[2] - nx;
      Integer ny=ABCDsizes[1] - nx;
      Real ABCD[nx + ny,nx + nu]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          matrixName,
          nx + ny,
          nx + nu);

    public
      output Real A[nx,nx]=ABCD[1:nx, 1:nx];
    algorithm

    end ReadMatrixA2;

## Modelica_LinearSystems2.Internal.Streams.ReadMatrixB

Read the input matrix of a state space system

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
String | fileName | DataDir + "abcd.mat" |
String | matrixName | "ABCD" | Name of the generalized state space system matrix

### Outputs

Type | Name | Description
--- | --- | ---
Real | B[nx, nu] |

### Modelica definition

    function ReadMatrixB "Read the input matrix of a state space system"
      input String fileName=DataDir + "abcd.mat";
      input String matrixName="ABCD"
        "Name of the generalized state space system matrix";

    protected
      Real sizeA[1,1]=Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          "nx",
          1,
          1);
      Integer ABCDsizes[2]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixOnFileSize(fileName,
          matrixName);
      Integer nx=integer(sizeA[1, 1]);
      Integer nu=ABCDsizes[2] - nx;
      Integer ny=ABCDsizes[1] - nx;
      Real ABCD[nx + ny,nx + nu]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          matrixName,
          nx + ny,
          nx + nu);
    public
      output Real B[nx,nu]=ABCD[1:nx, nx + 1:nx + nu];
    algorithm

    end ReadMatrixB;

## Modelica_LinearSystems2.Internal.Streams.ReadMatrixB2

Read the input matrix of a state space system

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
String | fileName | DataDir + "abcd.mat" |
String | matrixName | "ABCD" | Name of the generalized state space system matrix
Integer | nx |  | System order
Integer | nu |  | number of inputs

### Outputs

Type | Name | Description
--- | --- | ---
Real | B[nx, nu] |

### Modelica definition

    function ReadMatrixB2 "Read the input matrix of a state space system"
      input String fileName=DataDir + "abcd.mat";
      input String matrixName="ABCD"
        "Name of the generalized state space system matrix";
      input Integer nx "System order";
      input Integer nu "number of inputs";

    protected
      Integer ABCDsizes[2]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixOnFileSize(fileName,
          matrixName);

      Real ABCD[ABCDsizes[1],nx + nu]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          matrixName,
          ABCDsizes[1],
          nx + nu);

    public
      output Real B[nx,nu]=ABCD[1:nx, nx + 1:nx + nu];
    algorithm

    end ReadMatrixB2;

## Modelica_LinearSystems2.Internal.Streams.ReadMatrixC

Read the output matrix of a state space system

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
String | fileName | DataDir + "abcd.mat" |
String | matrixName | "ABCD" | Name of the generalized state space system matrix

### Outputs

Type | Name | Description
--- | --- | ---
Real | C[ny, nx] |

### Modelica definition

    function ReadMatrixC "Read the output matrix of a state space system"
      input String fileName=DataDir + "abcd.mat";
      input String matrixName="ABCD"
        "Name of the generalized state space system matrix";

    protected
      Real sizeA[1,1]=Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          "nx",
          1,
          1);
      Integer ABCDsizes[2]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixOnFileSize(fileName,
          matrixName);
      Integer nx=integer(sizeA[1, 1]);
      Integer nu=ABCDsizes[2] - nx;
      Integer ny=ABCDsizes[1] - nx;
      Real ABCD[nx + ny,nx + nu]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          matrixName,
          nx + ny,
          nx + nu);
    public
      output Real C[ny,nx]=ABCD[nx + 1:nx + ny, 1:nx];
    algorithm

    end ReadMatrixC;

## Modelica_LinearSystems2.Internal.Streams.ReadMatrixC2

Read the output matrix of a state space system

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
String | fileName | DataDir + "abcd.mat" |
String | matrixName | "ABCD" | Name of the generalized state space system matrix
Integer | nx |  | System order
Integer | ny |  | number of outputs

### Outputs

Type | Name | Description
--- | --- | ---
Real | C[ny, nx] |

### Modelica definition

    function ReadMatrixC2
      "Read the output matrix of a state space system"
      input String fileName=DataDir + "abcd.mat";
      input String matrixName="ABCD"
        "Name of the generalized state space system matrix";
      input Integer nx "System order";
      input Integer ny "number of outputs";
    protected
      Integer ABCDsizes[2]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixOnFileSize(fileName,
          matrixName);

      Real ABCD[nx + ny,ABCDsizes[2]]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          matrixName,
          nx + ny,
          ABCDsizes[2]);

    public
      output Real C[ny,nx]=ABCD[nx + 1:nx + ny, 1:nx];
    algorithm

    end ReadMatrixC2;

## Modelica_LinearSystems2.Internal.Streams.ReadMatrixD

Read the feed forward matrix of a state space system

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
String | fileName | DataDir + "abcd.mat" |
String | matrixName | "ABCD" | Name of the generalized state space system matrix

### Outputs

Type | Name | Description
--- | --- | ---
Real | D[ny, nu] |

### Modelica definition

    function ReadMatrixD
      "Read the feed forward matrix of a state space system"
      input String fileName=DataDir + "abcd.mat";
      input String matrixName="ABCD"
        "Name of the generalized state space system matrix";

    protected
      Real sizeA[1,1]=Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          "nx",
          1,
          1);
      Integer ABCDsizes[2]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixOnFileSize(fileName,
          matrixName);
      Integer nx=integer(sizeA[1, 1]);
      Integer nu=ABCDsizes[2] - nx;
      Integer ny=ABCDsizes[1] - nx;
      Real ABCD[nx + ny,nx + nu]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          matrixName,
          nx + ny,
          nx + nu);
    public
      output Real D[ny,nu]=ABCD[nx + 1:nx + ny, nx + 1:nx + nu];
    algorithm

    end ReadMatrixD;

## Modelica_LinearSystems2.Internal.Streams.ReadMatrixD2

Read the feed forward matrix of a state space system

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
String | fileName | DataDir + "abcd.mat" |
String | matrixName | "ABCD" | Name of the generalized state space system matrix
Integer | nx |  | System order
Integer | nu |  | number of inputs
Integer | ny |  | number of outputs

### Outputs

Type | Name | Description
--- | --- | ---
Real | D[ny, nu] |

### Modelica definition

    function ReadMatrixD2
      "Read the feed forward matrix of a state space system"
      input String fileName=DataDir + "abcd.mat";
      input String matrixName="ABCD"
        "Name of the generalized state space system matrix";
      input Integer nx "System order";
      input Integer nu "number of inputs";
      input Integer ny "number of outputs";

    protected
      Real ABCD[nx + ny,nx + nu]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          matrixName,
          nx + ny,
          nx + nu);

    public
      output Real D[ny,nu]=ABCD[nx + 1:nx + ny, nx + 1:nx + nu];
    algorithm

    end ReadMatrixD2;

## Modelica_LinearSystems2.Internal.Streams.readMatrixInternal

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
String | fileName |  | file name
String | matrixName |  | matrix name
Integer | m |  | number of rows
Integer | n |  | numbre of coloumns

### Outputs

Type | Name | Description
--- | --- | ---
Real | A[m, n] | matrix to read

### Modelica definition

    function readMatrixInternal
      input String fileName "file name";
      input String matrixName "matrix name";
      input Integer m "number of rows";
      input Integer n "numbre of coloumns";
      output Real A[m,n] "matrix to read";
    external "C" Modelica_LinearSystem2_readMatrixInternal(
        fileName,
        matrixName,
        A,
        m,
        n);
    end readMatrixInternal;

## Modelica_LinearSystems2.Internal.Streams.readMatrixOnFileSize

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
String | fileName |  | file name
String | matrixName |  | matrix name

### Outputs

Type | Name | Description
--- | --- | ---
Integer | dim[2] | matrix to read

### Modelica definition

    function readMatrixOnFileSize
      input String fileName "file name";
      input String matrixName "matrix name";
      output Integer dim[2] "matrix to read";
    external "C" readMatrixSizeEx(
        fileName,
        matrixName,
        dim);
    end readMatrixOnFileSize;

## Modelica_LinearSystems2.Internal.Streams.ReadSystemDimension

Read the order nx of state matrix and the numbers nu and ny of inputs and outputs

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
String | fileName | DataDir + "ss_siso.mat" |
String | matrixName | "ABCD" | Name of the generalized state space system matrix

### Outputs

Type | Name | Description
--- | --- | ---
Integer | xuy[3] |

### Modelica definition

    function ReadSystemDimension
      "Read the order nx of state matrix and the numbers nu and ny of inputs and outputs"
      import Modelica_LinearSystems2.StateSpace;
      input String fileName=DataDir + "ss_siso.mat";
      input String matrixName="ABCD"
        "Name of the generalized state space system matrix";
      output Integer xuy[3];

    protected
      Real sizeA[1,1]=Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          "nx",
          1,
          1);

      Integer ABCDsizes[2]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixOnFileSize(fileName,
          matrixName);

    algorithm
      xuy[1] := integer(sizeA[1, 1]);
      xuy[2] := ABCDsizes[2] - xuy[1];
      xuy[3] := ABCDsizes[1] - xuy[1];

    end ReadSystemDimension;

## Modelica_LinearSystems2.Internal.Streams.ReadSystemDimension2

Read the order nx of state matrix and the numbers nu and ny of inputs and outputs

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
String | fileName | DataDir + "ss_siso.mat" |
String | matrixName | "ABCD" | Name of the generalized state space system matrix

### Outputs

Type | Name | Description
--- | --- | ---
Integer | xuy[3] |

### Modelica definition

    function ReadSystemDimension2
      "Read the order nx of state matrix and the numbers nu and ny of inputs and outputs"
      import Modelica_LinearSystems2.StateSpace;
      import Modelica_LinearSystems2.Internal.Streams;
      input String fileName=DataDir + "ss_siso.mat";
      input String matrixName="ABCD"
        "Name of the generalized state space system matrix";
      output Integer xuy[3];

    protected
      Real sizeA[1,1]=Modelica_LinearSystems2.Internal.Streams.readMatrixInternal(
          fileName,
          "nx",
          1,
          1);

      Integer ABCDsizes[2]=
          Modelica_LinearSystems2.Internal.Streams.readMatrixOnFileSize(fileName,
          matrixName);

    algorithm
      xuy[1] := integer(sizeA[1, 1]);
      xuy[2] := ABCDsizes[2] - xuy[1];
      xuy[3] := ABCDsizes[1] - xuy[1];

    end ReadSystemDimension2;

## Modelica_LinearSystems2.Internal.Streams.stateSpaceString_html

### Inputs

Type | Name | Default | Description
--- | --- | --- | ---
StateSpace | ss |  | State space system to be transformed in a String representation
Integer | significantDigits | 12 | Number of significant digits that are shown
String | name | "ss" | Independent variable name used for printing

### Outputs

Type | Name | Description
--- | --- | ---
String | s |

### Modelica definition

    function stateSpaceString_html
      import Modelica;
      import Modelica_LinearSystems2.StateSpace;
      import Modelica.Utilities.Strings;

      input StateSpace ss
        "State space system to be transformed in a String representation";
      input Integer significantDigits=12
        "Number of significant digits that are shown";
      input String name="ss" "Independent variable name used for printing";
      output String s="";
    protected
      String space=Strings.repeat(5);
      String space2=Strings.repeat(3);
      String space3=Strings.repeat(8);
      Integer nx=size(ss.A, 1);
      Integer nu=size(ss.B, 2);
      Integer ny=size(ss.C, 1);
      Integer sizeD=size(ss.D, 2);
      Integer stringMaxLength;
      Boolean namesExist=false;

    algorithm
    //Checking if name arrays are empty
      for i in 1:nx loop
        namesExist := namesExist or (ss.xNames[i] <> "");
      end for;

      for i in 1:ny loop
        namesExist := namesExist or (ss.yNames[i] <> "");
      end for;

      for i in 1:nu loop
        namesExist := namesExist or (ss.uNames[i] <> "");
      end for;

      if namesExist then
        Modelica.Utilities.Streams.print("namesExist == true");
      else
        Modelica.Utilities.Streams.print("namesExist == false");
      end if;

      stringMaxLength := max(size(ss.xNames, 1), min(size(ss.yNames, 1),
        11));
    //, size(ss.uNames,1)));
                                                                   //, max(size(ss.yNames), size(ss.uNames))

      if nx == 0 and sizeD == 0 then
        s := name + ".A = []<br>  " + name + ".B = []<br>   " + name + ".C = [] <br>   " + name + ".D = []";
      else
        s := "<br>" + name + ".A = <br>";

    //Horizontal
    // Two alternatives when printing state names
        if namesExist == false then
    //    if ss.xNames == fill(" ", size(A, 2)) then

          s := s + Strings.repeat(stringMaxLength + significantDigits - 1) +
            "x1 ";
        else
          s := s + Strings.repeat(11 + significantDigits - min(Strings.length(
            ss.xNames[1]), 11)) + Strings.repeat(min(Strings.length(ss.xNames[
            1]), 11)) + " " + Strings.substring(
                ss.xNames[1],
                1,
                min(Strings.length(ss.xNames[1]), 11));
        end if;

        for i in 2:nx loop

    //Two alternatives when printing state names

          if namesExist == false then
            s := s + Strings.repeat(significantDigits + 11 - Strings.length("x"
               + String(i - 1))) + "x" + String(i) + " ";
          else
            s := s + " " + Strings.repeat(significantDigits + 11 - min(
              Strings.length(ss.xNames[i - 1]), 11)) + Strings.substring(
                  ss.xNames[i],
                  1,
                  min(Strings.length(ss.xNames[i]), 11));

          end if;

        end for;
        s := s + "<br>";

        for i in 1:nx loop
    //Vertical
    //Two alternatives when printing state names
          if namesExist == false then
            s := s + space + "x" + String(i) + " ";
          else
            s := s + Strings.repeat(significantDigits + 11 - min(Strings.length(
              ss.xNames[i]), 11)) + Strings.substring(
                  ss.xNames[i],
                  1,
                  min(Strings.length(ss.xNames[i]), 11)) + " ";

          end if;

          for j in 1:nx loop
            if ss.A[i, j] >= 0 then
              s := s + " ";
            end if;
            s := s + String(ss.A[i, j], significantDigits=significantDigits) +
              Strings.repeat(significantDigits + 11 - Strings.length(String(abs(
              ss.A[i, j]), significantDigits=significantDigits)));
          end for;
          s := s + "<br>";
        end for;
    //--------------------------------------------------------------------------------------------------------------------------------------------------
        s := s + "<br>" + name + ".B = <br>";
     //Horizontal
    // Two alternatives when printing state names
        if namesExist == false then
          s := s + Strings.repeat(stringMaxLength + significantDigits - 1) +
            "u1 ";
        else
          s := s + Strings.repeat(11 + significantDigits - min(Strings.length(
            ss.uNames[1]), 11)) + Strings.repeat(min(Strings.length(ss.uNames[
            1]), 11)) + " " + Strings.substring(
                ss.uNames[1],
                1,
                min(Strings.length(ss.uNames[1]), 11));
        end if;

        for i in 2:nu loop
    //Two alternatives when printing state names
          if namesExist == false then
            s := s + Strings.repeat(significantDigits + 11 - Strings.length("u"
               + String(i - 1))) + "u" + String(i) + " ";
          else
            s := s + " " + Strings.repeat(significantDigits + 11 - min(
              Strings.length(ss.uNames[i - 1]), 11)) + Strings.substring(
                  ss.uNames[i],
                  1,
                  min(Strings.length(ss.uNames[i]), 11));
          end if;
        end for;
        s := s + "<br>";
        for i in 1:nx loop

    //Vertical
    //Two alternatives when printing state names
          if namesExist == false then
            s := s + space + "x" + String(i) + " ";
          else
            s := s + Strings.repeat(significantDigits + 11 - min(Strings.length(
              ss.xNames[i]), 11)) + Strings.substring(
                  ss.xNames[i],
                  1,
                  min(Strings.length(ss.xNames[i]), 11)) + " ";

          end if;

          for j in 1:nu loop
            if ss.B[i, j] >= 0 then
              s := s + " ";
            end if;
            s := s + String(ss.B[i, j], significantDigits=significantDigits) +
              Strings.repeat(significantDigits + 11 - Strings.length(String(abs(
              ss.B[i, j]), significantDigits=significantDigits)));
          end for;
          s := s + "<br>";
        end for;

    //--------------------------------------------------------------------------------------------------------------------------------------------------
        s := s + "<br>" + name + ".C = <br>";
     //Horizontal
    // Two alternatives when printing state names
        if namesExist == false then
          s := s + Strings.repeat(stringMaxLength + significantDigits - 1) +
            "x1 ";
        else
          s := s + Strings.repeat(11 + significantDigits - min(Strings.length(
            ss.xNames[1]), 11)) + Strings.repeat(min(Strings.length(ss.xNames[
            1]), 11)) + " " + Strings.substring(
                ss.xNames[1],
                1,
                min(Strings.length(ss.xNames[1]), 11));
        end if;

        for i in 2:nx loop
    //Two alternatives when printing state names
          if namesExist == false then
            s := s + Strings.repeat(significantDigits + 11 - Strings.length("x"
               + String(i - 1))) + "x" + String(i) + " ";
          else
            s := s + " " + Strings.repeat(significantDigits + 11 - min(
              Strings.length(ss.xNames[i - 1]), 11)) + Strings.substring(
                  ss.xNames[i],
                  1,
                  min(Strings.length(ss.xNames[i]), 11));
          end if;
        end for;
        s := s + "<br>";

        for i in 1:nu loop
    //Vertical
    //Two alternatives when printing state names
          if namesExist == false then
            s := s + space + "y" + String(i) + " ";
          else
            s := s + Strings.repeat(significantDigits + 11 - min(Strings.length(
              ss.yNames[i]), 11)) + Strings.substring(
                  ss.yNames[i],
                  1,
                  min(Strings.length(ss.yNames[i]), 11)) + " ";

          end if;

          for j in 1:nx loop
            if ss.C[i, j] >= 0 then
              s := s + " ";
            end if;
            s := s + String(ss.C[i, j], significantDigits=significantDigits) +
              Strings.repeat(significantDigits + 11 - Strings.length(String(abs(
              ss.C[i, j]), significantDigits=significantDigits)));
          end for;
          s := s + "<br>";
        end for;
    //--------------------------------------------------------------------------------------------------------------------------------------------------
        s := s + "<br>" + name + ".D = <br>";
     //Horizontal
    // Two alternatives when printing state names
        if namesExist == false then
          s := s + Strings.repeat(stringMaxLength + significantDigits - 1) +
            "u1 ";
        else
          s := s + Strings.repeat(11 + significantDigits - min(Strings.length(
            ss.uNames[1]), 11)) + Strings.repeat(min(Strings.length(ss.uNames[
            1]), 11)) + " " + Strings.substring(
                ss.uNames[1],
                1,
                min(Strings.length(ss.uNames[1]), 11));
        end if;

        for i in 2:nu loop
    //Two alternatives when printing state names
          if namesExist == false then
            s := s + Strings.repeat(significantDigits + 11 - Strings.length("u"
               + String(i - 1))) + "u" + String(i) + " ";
          else
            s := s + " " + Strings.repeat(significantDigits + 11 - min(
              Strings.length(ss.uNames[i - 1]), 11)) + Strings.substring(
                  ss.uNames[i],
                  1,
                  min(Strings.length(ss.uNames[i]), 11));
          end if;
        end for;
        s := s + "<br>";
        for i in 1:ny loop
    //Vertical
    //Two alternatives when printing state names
          if namesExist == false then
            s := s + space + "y" + String(i) + " ";
          else
            s := s + Strings.repeat(significantDigits + 11 - min(Strings.length(
              ss.yNames[i]), 11)) + Strings.substring(
                  ss.yNames[i],
                  1,
                  min(Strings.length(ss.yNames[i]), 11)) + " ";

          end if;

          for j in 1:nu loop
            if ss.D[i, j] >= 0 then
              s := s + " ";
            end if;
            s := s + String(ss.D[i, j], significantDigits=significantDigits) +
              Strings.repeat(significantDigits + 11 - Strings.length(String(abs(
              ss.D[i, j]), significantDigits=significantDigits)));
          end for;
          s := s + "<br>";
        end for;

      end if;

    end stateSpaceString_html;