{"id":2603,"date":"2010-09-24T14:11:03","date_gmt":"2010-09-24T14:11:03","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2010\/09\/24\/wise-goto-block\/"},"modified":"2010-09-24T14:19:15","modified_gmt":"2010-09-24T14:19:15","slug":"wise-goto-block","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2010\/09\/24\/wise-goto-block\/","title":{"rendered":"Wise Goto Block"},"content":{"rendered":"\r\n<p xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\"><introduction><\/introduction>Greg's Pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/9876-wise-goto-block\">\"Wise Goto-Block\"<\/a>, by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/22152\">Markus Baranyai<\/a>.<\/p>\r\nNOTE: Today's Pick comes to us from guest blogger Greg Wolff. This is Greg's first Pick; we're hoping there will be many more!\r\n[Brett and Jiro]\r\n<h3>Contents<\/h3>\r\n<ul>\r\n\t<li><a href=\"#2\">Signal Management Challenges Can Be Addressed With The Wise GOTO Block<\/a><\/li>\r\n\t<li><a href=\"#4\">Enhance Simulink Block Behavior With Callback Functions<\/a><\/li>\r\n<\/ul>\r\nWhile I am not a strong proponent of using the GOTO and FROM blocks in Simulink Models, I do want to point out that if you\r\nchoose to use these blocks in your model, Markus Baranyai\u2019s submission makes it convenient to apply some of the best practices\r\nsurrounding the use of GOTO and FROM blocks.\r\n<h3>Signal Management Challenges Can Be Addressed With The Wise GOTO Block<a name=\"2\" title=\"2\"><\/a><\/h3>\r\nSignal management in Simulink can be challenging if there are signals traveling across the Simulink model diagram, or there\r\nare lots of crossing signal lines. The GOTO and FROM blocks attempt to relieve this challenge, but end up introducing challenges\r\nof their own. There are some best practices that can be employed to make GOTO and FROM blocks more usable. This is where Markus\u2019s\r\nMATLAB Central submission provides a lot of value. It enforces best practices by applying the same\r\n<ul>\r\n\t<li>Tag name<\/li>\r\n\t<li>Size<\/li>\r\n\t<li>Background color<\/li>\r\n\t<li>Naming convention<\/li>\r\n<\/ul>\r\nto both the GOTO and FROM block:\r\n\r\n<img decoding=\"async\" vspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/pick\/..\/images\/pick\/vdp_with_goto.png\" hspace=\"5\" \/>\r\n<h3>Enhance Simulink Block Behavior With Callback Functions<a name=\"4\" title=\"4\"><\/a><\/h3>\r\nMany users are unaware that the behavior of blocks within Simulink can be enhanced through the use of block or model callback\r\nfunctions. These are functions that are executed when certain events occur. In the case of this entry, Markus takes advantage\r\nof the NameChangeFcn, which is a function that is called when the name of the block changes.\r\n\r\nFor more on block callback functions, please see the following our <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/simulink\/ug\/f4-122589.html#f4-45560\">documentation page<\/a> on the topic.\r\n\r\n<a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2603#respond\">Comments?<\/a>\r\n\r\n<script language=\"JavaScript\">              <!--\r\n\r\nfunction grabCode_4145b81c9c334dbb85272b1469ad8f33() {          \/\/ Remember the title so we can use it in the new page          title = document.title;\r\n\r\n\/\/ Break up these strings so that their presence          \/\/ in the Javascript doesn\\\\\\\\\\\\'t mess up the search for          \/\/ the MATLAB code.          t1=\\\\\\\\\\\\'4145b81c9c334dbb85272b1469ad8f33 \\\\\\\\\\\\' + \\\\\\\\\\\\'##### \\\\\\\\\\\\' + \\\\\\\\\\\\'SOURCE BEGIN\\\\\\\\\\\\' + \\\\\\\\\\\\' #####\\\\\\\\\\\\';          t2=\\\\\\\\\\\\'##### \\\\\\\\\\\\' + \\\\\\\\\\\\'SOURCE END\\\\\\\\\\\\' + \\\\\\\\\\\\' #####\\\\\\\\\\\\' + \\\\\\\\\\\\' 4145b81c9c334dbb85272b1469ad8f33\\\\\\\\\\\\';\r\n\r\nb=document.getElementsByTagName(\\\\\\\\\\\\'body\\\\\\\\\\\\')[0];          i1=b.innerHTML.indexOf(t1)+t1.length;          i2=b.innerHTML.indexOf(t2);\r\n\r\ncode_string = b.innerHTML.substring(i1, i2);          code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,\\\\\\\\\\\\'--\\\\\\\\\\\\');\r\n\r\n\/\/ Use \/x3C\/g instead of the less-than character to avoid errors           \/\/ in the XML parser.          \/\/ Use \\\\\\\\\\\\'\\x26#60;\\\\\\\\\\\\' instead of \\\\\\\\\\\\'<\\\\\\\\\\\\' so that the XML parser          \/\/ doesn\\\\\\\\\\\\'t go ahead and substitute the less-than character.           code_string = code_string.replace(\/\\x3C\/g, \\\\\\\\\\\\'\\x26#60;\\\\\\\\\\\\');\r\n\r\nauthor = \\\\\\\\\\\\'Brett Shoelson\\\\\\\\\\\\';          copyright = \\\\\\\\\\\\'Copyright 2010 The MathWorks, Inc.\\\\\\\\\\\\';\r\n\r\nw = window.open();          d = w.document;          d.write(\\\\\\\\\\\\'\r\n<pre>\\n\\\\\\\\\\\\');            \r\n        d.write(code_string);            \r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.            \r\n        if ((author.length > 0) || (copyright.length > 0)) {            \r\n            d.writeln(\\\\\\\\\\\\'\\\\\\\\\\\\');            \r\n            d.writeln(\\\\\\\\\\\\'%%\\\\\\\\\\\\');            \r\n            if (author.length > 0) {            \r\n                d.writeln(\\\\\\\\\\\\'% _\\\\\\\\\\\\' + author + \\\\\\\\\\\\'_\\\\\\\\\\\\');            \r\n            }            \r\n            if (copyright.length > 0) {            \r\n                d.writeln(\\\\\\\\\\\\'% _\\\\\\\\\\\\' + copyright + \\\\\\\\\\\\'_\\\\\\\\\\\\');            \r\n            }            \r\n        }            \r\n\r\n        d.write(\\\\\\\\\\\\'<\/pre>\r\n\\n\\\\\\\\\\\\');\r\n\r\nd.title = title + \\\\\\\\\\\\' (MATLAB code)\\\\\\\\\\\\';        d.close();        }\r\n\r\n--><\/script>\r\n\r\n<p style=\"font-weight: lighter; font-size: xx-small; color: gray; font-style: italic; text-align: right\"><a href=\"javascript:grabCode_4145b81c9c334dbb85272b1469ad8f33()\"><span style=\"font-size: x-small; font-style: italic\">Get\r\nthe MATLAB code\r\n<noscript><\/noscript><\/span><\/a>\r\n\r\nPublished with MATLAB\u00ae 7.10\r\n\r\n<!--\r\n4145b81c9c334dbb85272b1469ad8f33 ##### SOURCE BEGIN #####\r\n%% Wise Goto Block\r\n%\r\n% Greg's Pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/9876-wise-goto-block \"Wise Goto-Block\">, by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/22152 Markus Baranyai>.\r\n%\r\n% NOTE: Today's Pick comes to us from guest blogger Greg Wolff. This is\r\n% Greg's first Pick; we're hoping there will be many more! [Brett and Jiro]\r\n\r\n%%\r\n%\r\n% While I am not a strong proponent of using the GOTO and FROM blocks in Simulink Models,\r\n% I do want to point out that if you choose to use these blocks in your model,\r\n% Markus Baranyai\u00e2\u20ac\u2122s submission makes it convenient to apply some of the best\r\n% practices surrounding the use of GOTO and FROM blocks.\r\n%\r\n%% Signal Management Challenges Can Be Addressed With The Wise GOTO Block\r\n% Signal management in Simulink can be challenging if there are signals\r\n% traveling across the Simulink model diagram, or there are lots of crossing\r\n% signal lines. The GOTO and FROM blocks attempt to relieve this challenge,\r\n% but end up introducing challenges of their own. There are some best practices\r\n% that can be employed to make GOTO and FROM blocks more usable. This is where\r\n% Markus\u00e2\u20ac\u2122s MATLAB Central submission provides a lot of value.\r\n% It enforces best practices by applying the same\r\n%\r\n%\r\n% * Tag name\r\n% * Size\r\n% * Background color\r\n% * Naming convention\r\n%\r\n% to both the GOTO and FROM block:\r\n%\r\n%%\r\n%\r\n% <<vdp_with_goto.png>>\r\n%\r\n%% Enhance Simulink Block Behavior With Callback Functions\r\n% Many users are unaware that the behavior of blocks within Simulink can be\r\n% enhanced through the use of block or model callback functions. These are\r\n% functions that are executed when certain events occur. In the case of this\r\n% entry, Markus takes advantage of the NameChangeFcn, which is a function\r\n% that is called when the name of the block changes.\r\n%\r\n% For more on block callback functions, please see the following our\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2010b\/toolbox\/simulink\/ug\/f4-122589.html#f4-45560 documentation page> on the topic.\r\n%\r\n%%\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2603#respond  Comments?>\r\n\r\n##### SOURCE END ##### 4145b81c9c334dbb85272b1469ad8f33\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\nGreg's Pick this week is \"Wise Goto-Block\", by Markus Baranyai.\r\nNOTE: Today's Pick comes to us from guest blogger Greg Wolff. This is Greg's first Pick; we're hoping there will be many... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2010\/09\/24\/wise-goto-block\/\">read more >><\/a><\/p>","protected":false},"author":44,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2603"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2603"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2603\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}