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<blockquote><pre>\n<strong>y</strong> = <strong>u</strong>[1] + <strong>u</strong>[2] + ...;\n</pre></blockquote>\n<p>\nExample:\n</p>\n<blockquote><pre>\n   parameter:   nin = 3;\n\nresults in the following equations:\n\n   y = u[1] + u[2] + u[3];\n</pre></blockquote>\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}})}));
end Sum;