{"id":2209,"date":"2013-05-10T13:51:42","date_gmt":"2013-05-10T18:51:42","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/?p=2209"},"modified":"2013-05-10T13:51:42","modified_gmt":"2013-05-10T18:51:42","slug":"sum-block-round-or-rectangular","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2013\/05\/10\/sum-block-round-or-rectangular\/","title":{"rendered":"Sum Block: Round or Rectangular?"},"content":{"rendered":"<p>Working in technical support, I see a lot of Simulink models from users. I have realized that many users do not know how to, or do not take the time to configure the ports of the <a href=\"https:\/\/www.mathworks.com\/help\/simulink\/slref\/add.html\">Sum<\/a> block.<\/p>\r\n\r\n<p>For example, when I see things like this, it makes my eyes hurt a little:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q2\/lookingBad.png\" alt=\"Unusual configurations of the Sum block\" \/><\/p>\r\n\r\n<p>Here are a few tips to format the Sum block to make your models easier to understand.<\/p>\r\n\r\n<p><strong>Round Sum block<\/strong><\/p>\r\n\r\n<p>When you drag the Sum block from the Simulink Library Browser, its <strong>Icon Shape<\/strong> is set to <strong>Round<\/strong>, and it has one input port on the left and one on the bottom:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q2\/defaultSumBlock.png\" alt=\"Default configuration of the Sum block\" \/><\/p>\r\n\r\n<p>When the Sum block Icon Shape is set to Round, the ports are spread evenly from top to bottom and the vertical bar \"|\" can be used to skip one position. For example, if we want to add a port on top of the block, we can modify the list of signs:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q2\/threeSumBlock.png\" alt=\"3 ports configuration of the Sum block\" \/><\/p>\r\n\r\n<p><strong>Rectangular Sum block<\/strong><\/p>\r\n\r\n<p>If you change the <strong>Icon Shape<\/strong> property of the default Sum block to <strong>Rectangular<\/strong>, the block will look like the following:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q2\/defaultRectangularSumBlock.png\" alt=\"Rectangular configuration of the Sum block\" \/><\/p>\r\n\r\n<p>Personally, I can not think of a good reason for skipping a port in Rectangular shape. So I almost always remove the \"|\" when I change the shape to Rectangular.<\/p>\r\n\r\n <p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q2\/RectangularSumBlock.png\" alt=\"Rectangular configuration of the Sum block\" \/><\/p>\r\n\r\n<p><strong>Sum of Elements<\/strong><\/p>\r\n\r\n<p>One way I like to use the Sum block is to sum all the elements of a vector or matrix:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q2\/sumOfAllElements.png\" alt=\"Sum of elements configuration of the Sum block\" \/><\/p>\r\n\r\n<p>For matrices, the Sum block can also be configured to Sum only over one specific dimension:<\/p>\r\n\r\n <p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q2\/sumOfElements.png\" alt=\"Sum of elements configuration of the Sum block\" \/><\/p>\r\n\r\n<p><strong>Round or Rectangular?<\/strong><\/p>\r\n\r\n<p>One question remains: <em>When should the Sum block be Round and when should it be Rectangular?<\/em><\/p>\r\n\r\n<p>There is no absolute rule, but personally I like to use the Rectangular shape when implementing equations that flow from left to right, without obvious feedback. For example:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q2\/rectangularFlow.png\" alt=\"When to use configuration of the Sum block\" \/><\/p>\r\n\r\n<p>I keep the Round shape for when I want to make it obvious that there is a feedback involved:<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q2\/roundForFeedback.png\" alt=\"When to use Round configuration of the Sum block\" \/><\/p>\r\n\r\n<p><strong>Now it's your turn<\/strong><\/p>\r\n\r\n<p>Please share with us if you have rules or guidelines on the format of your blocks by leaving a <a href=\"https:\/\/blogs.mathworks.com\/seth\/?p=2209&#comment\">comment here<\/a>.<\/p>\r\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2013Q2\/roundForFeedback.png\" onError=\"this.style.display ='none';\" \/><\/div><p>Working in technical support, I see a lot of Simulink models from users. I have realized that many users do not know how to, or do not take the time to configure the ports of the Sum block.\r\n\r\nFor... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2013\/05\/10\/sum-block-round-or-rectangular\/\">read more >><\/a><\/p>","protected":false},"author":41,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[30,11,33],"tags":[325,326,324],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/2209"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=2209"}],"version-history":[{"count":16,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/2209\/revisions"}],"predecessor-version":[{"id":2250,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/2209\/revisions\/2250"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=2209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=2209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=2209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}