Sum

block Sum "Output the sum of the elements of the input vector"
    extends Interfaces.MISO;

    parameter Real k[nin] = ones(nin) "Optional: sum coefficients";
equation
    y = k * u;

    annotation (
        defaultComponentName = "sum1",
        Documentation(info = "<html>\n<p>\nThis blocks computes output <strong>y</strong> as\n<em>sum</em> of the elements of the input signal vector\n<strong>u</strong>:\n</p>\n<pre>\n    <strong>y</strong> = <strong>u</strong>[1] + <strong>u</strong>[2] + ...;\n</pre>\n<p>\nExample:\n</p>\n<pre>\n     parameter:   nin = 3;\n\n  results in the following equations:\n\n     y = u[1] + u[2] + u[3];\n</pre>\n\n</html>"),
        Icon(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Line(points = {
                    {26, 42}, 
                    {-34, 42}, 
                    {6, 2}, 
                    {-34, -38}, 
                    {26, -38}})}),
        Diagram(
            coordinateSystem(
                preserveAspectRatio = true,
                extent = {
                    {-100, -100}, 
                    {100, 100}}),
            graphics = {
                Rectangle(
                    extent = {
                        {-100, -100}, 
                        {100, 100}},
                    lineColor = {0, 0, 255},
                    fillColor = {255, 255, 255},
                    fillPattern = FillPattern.Solid), 
                Line(points = {
                    {26, 42}, 
                    {-34, 42}, 
                    {6, 2}, 
                    {-34, -38}, 
                    {26, -38}})}));
end Sum;