{"id":2930,"date":"2011-09-23T13:15:36","date_gmt":"2011-09-23T13:15:36","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2011\/09\/23\/import-test-cases-from-excel-into-simulink\/"},"modified":"2011-09-23T13:15:36","modified_gmt":"2011-09-23T13:15:36","slug":"import-test-cases-from-excel-into-simulink","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2011\/09\/23\/import-test-cases-from-excel-into-simulink\/","title":{"rendered":"Import Test Cases From Excel Into Simulink"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/32620\">Greg's<\/a> pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/31609-cmtdtool\">CMTDTOOL<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/33588\">Yasumitsu Ito<\/a>.\r\n      <\/p>\r\n   <\/introduction>\r\n   <h3>Contents<\/h3>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"#1\">Adding Test Cases for Your Simulink Model a Pain? Check out the CMTDTOOL<\/a><\/li>\r\n         <li><a href=\"#2\">Test Cases for Designs in Simulink?&#8230;.Booooriiiing!<\/a><\/li>\r\n         <li><a href=\"#3\">So It&#8217;s Easy, But What Else?<\/a><\/li>\r\n         <li><a href=\"#4\">So CMTDTOOL Brings Life and Vitality to Test Case Development?<\/a><\/li>\r\n         <li><a href=\"#5\">What Else Can CMTDTOOL Do For Me?<\/a><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <h3>Adding Test Cases for Your Simulink Model a Pain? Check out the CMTDTOOL<a name=\"1\"><\/a><\/h3>\r\n   <p>While the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011b\/toolbox\/simulink\/ug\/f15-109640.html\">Signal Builder<\/a> block provides a convenient way to store a variety of test cases for a particular model, it&#8217;s less convenient to create and\r\n      document the tests with it.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/greg\/TestingWithCMTDTOOL_Writeup\/cd010_xls2SignalBuilder_pic04.png\"> <\/p>\r\n   <p>Test vectors are nice to store in some tabular form, at which Excel&#8230;.errr excels.  But it&#8217;s a little tricky to try and apply\r\n      those nice tables of data to a Simulink model for testing.  Just highlight the test cases in Excel and the click the <i>\"Excel Selection to Signal Builder\"<\/i> button and CMTDTOOL will import test vectors from Excel into a Signal Builder block.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/greg\/TestingWithCMTDTOOL_Writeup\/cd010_xls2SignalBuilder_pic02.png\"> <\/p>\r\n   <p>This is something Simulink already provides an example for in MathWorks <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011b\/toolbox\/simulink\/ug\/f15-109640.html#bskwu0h-1\">documentation<\/a> but the CMTDTOOL wraps a nice GUI around this functionality. Now you can execute your nicely formatted test cases against\r\n      your model of your design.\r\n   <\/p>\r\n   <h3>Test Cases for Designs in Simulink?&#8230;.Booooriiiing!<a name=\"2\"><\/a><\/h3>\r\n   <p>Not many engineers enjoy discussing the testing of their designs.  Compared to designing and making stuff, testing  seems\r\n      tedious and uncomfortable. It&#8217;s similar to going to the local department of motor vehicles to get your driver&#8217;s license renewed:\r\n      it has to be done, but it involves a lot of waiting around with no comfortable place to sit.\r\n   <\/p>\r\n   <p>Testing is the essence of simulation. The whole reason we simulate is to test out ideas quickly with little risk.  And developing\r\n      better tests helps you produce better designs. We engineers just don&#8217;t enjoy making it a formal process with lots documentation.\r\n   <\/p>\r\n   <h3>So It&#8217;s Easy, But What Else?<a name=\"3\"><\/a><\/h3>\r\n   <p>Personally I think it is useful because it allows me to define test cases in a natural format and quickly apply them to my\r\n      Simulink model.\r\n   <\/p>\r\n   <p>CMTDTOOL is also well documented. Once you execute the set-up script, the documentation is available in the MATLAB Help Browser.<\/p>\r\n   <h3>So CMTDTOOL Brings Life and Vitality to Test Case Development?<a name=\"4\"><\/a><\/h3>\r\n   <p>Okay, that might be a little strong. A rose is still a rose no matter what name you give it. But certainly the CMTDTOOL can\r\n      make the process of applying documented test cases to Simulink models less tedious and time consuming.\r\n   <\/p>\r\n   <h3>What Else Can CMTDTOOL Do For Me?<a name=\"5\"><\/a><\/h3>\r\n   <p><b>Import Truth Tables from Excel<\/b> As the name implies, truth tables are tabular data that describe a set of actions based on a particular set of conditions.\r\n       Again we see the theme of importing tabular data from Excel.\r\n   <\/p>\r\n   <p>So this<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/greg\/TestingWithCMTDTOOL_Writeup\/cd020_xls2TruthTable_pic01.png\"> <\/p>\r\n   <p>becomes<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/greg\/TestingWithCMTDTOOL_Writeup\/cd020_xls2TruthTable_pic04.png\"> <\/p>\r\n   <p><b>Generate Model Test Harnesses<\/b> In more rigorous development environments it is not desirable to change the design specification for testing. That means,\r\n      <i>&#8220;Don&#8217;t add stuff to the model just to test it!&#8221;<\/i>  The test harness generation will create a new model that references the model under test. The application of the input data\r\n      and analysis of the system output data is done in the new model.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/greg\/TestingWithCMTDTOOL_Writeup\/cd040_makeharness_pic02.png\"> <\/p>\r\n   <p><b>Generate a Report (i.e. &#8220;Show Me the $$&#8221;)<\/b> In high integrity development processes, you haven&#8217;t done any testing until you have documentation that shows the results.\r\n       The CMTDTOOL provides a nice mechanism for some basic reporting on tests of Simulink designs and comparison of expected results\r\n      versus results from the Simulink simulation.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/greg\/TestingWithCMTDTOOL_Writeup\/cd060_runCMTDReport_pic08.png\"> <\/p>\r\n   <p>When engineers use Simulink to develop software specifications for flight code in airplanes, they need to demonstrate immense\r\n      amounts of documentation that prove the designs have been tested.  Automating the generation of the documentation certainly\r\n      makes the development process easier.\r\n   <\/p>\r\n   <p><b>Comments<\/b><\/p>\r\n   <p>If you would like to leave any comments regarding this post, please click <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2930#respond\">here<\/a>.\r\n   <\/p>\r\n   <p>Or you can leave a comment for Yasumitsu Ito <a href=\"<https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/31609-cmtdtool#comments\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_988266d95d9c47a4a65f5bd4b92dc10f() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='988266d95d9c47a4a65f5bd4b92dc10f ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 988266d95d9c47a4a65f5bd4b92dc10f';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        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 \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Greg Wolff';\r\n        copyright = 'Copyright 2011 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<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>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_988266d95d9c47a4a65f5bd4b92dc10f()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.13<br><\/p>\r\n<\/div>\r\n<!--\r\n988266d95d9c47a4a65f5bd4b92dc10f ##### SOURCE BEGIN #####\r\n%% Import Test Cases From Excel Into Simulink\r\n%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/32620 Greg's>\r\n% pick this week is \r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/31609-cmtdtool CMTDTOOL>\r\n% by <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/33588 Yasumitsu Ito>.\r\n% \r\n%% Adding Test Cases for Your Simulink Model a Pain? Check out the CMTDTOOL\r\n% While the <https:\/\/www.mathworks.com\/help\/releases\/R2011b\/toolbox\/simulink\/ug\/f15-109640.html Signal Builder> block provides a\r\n% convenient way to store a variety of test cases for a particular model,\r\n% it\u00e2\u20ac\u2122s less convenient to create and document the tests with it. \r\n% \r\n% <<cd010_xls2SignalBuilder_pic04.png>>\r\n% \r\n% Test vectors are nice\r\n% to store in some tabular form, at which Excel\u00e2\u20ac\u00a6.errr excels.  But\r\n% it\u00e2\u20ac\u2122s a little tricky to try and apply those nice tables of data to a\r\n% Simulink model for testing.  Just highlight the test cases in Excel and\r\n% the click the _\"Excel Selection to Signal Builder\"_ button and CMTDTOOL will import test vectors from Excel into a Signal Builder\r\n% block. \r\n% \r\n% <<cd010_xls2SignalBuilder_pic02.png>>\r\n% \r\n% This is something Simulink already provides an example for in MathWorks <https:\/\/www.mathworks.com\/help\/releases\/R2011b\/toolbox\/simulink\/ug\/f15-109640.html#bskwu0h-1 documentation> but the CMTDTOOL wraps a nice GUI around this functionality. Now you can execute your nicely formatted test cases against your\r\n% model of your design.\r\n% \r\n%% Test Cases for Designs in Simulink?\u00e2\u20ac\u00a6.Booooriiiing! \r\n% Not many engineers\r\n% enjoy discussing the testing of their designs.  Compared to designing and\r\n% making stuff, testing  seems tedious and uncomfortable. It\u00e2\u20ac\u2122s similar to\r\n% going to the local department of motor vehicles to get your driver\u00e2\u20ac\u2122s\r\n% license renewed: it has to be done, but it involves a lot of waiting\r\n% around with no comfortable place to sit. \r\n%\r\n% Testing is the essence of\r\n% simulation. The whole reason we simulate is to test out ideas quickly\r\n% with little risk.  And developing better tests helps you produce\r\n% better designs. We engineers just don\u00e2\u20ac\u2122t enjoy making it a formal process with lots\r\n% documentation. \r\n%\r\n%% So It\u00e2\u20ac\u2122s Easy, But What Else? \r\n% Personally I think it is useful because it\r\n% allows me to define test cases in a natural format and quickly apply them\r\n% to my Simulink model. \r\n%\r\n% CMTDTOOL is also well documented. Once you execute\r\n% the set-up script, the documentation is available in the MATLAB Help\r\n% Browser.\r\n% \r\n% \r\n%% So CMTDTOOL Brings Life and Vitality to Test Case Development? \r\n% Okay, that might be a little strong. A rose is still a rose\r\n% no matter what name you give it. But certainly the CMTDTOOL can make the\r\n% process of applying documented test cases to Simulink models less tedious\r\n% and time consuming.\r\n% \r\n%% What Else Can CMTDTOOL Do For Me? \r\n% *Import Truth Tables from Excel*\r\n% As the\r\n% name implies, truth tables are tabular data that describe a set of\r\n% actions based on a particular set of conditions.  Again we see the theme\r\n% of importing tabular data from Excel. \r\n% \r\n% So this\r\n%\r\n% <<cd020_xls2TruthTable_pic01.png>>\r\n% \r\n% becomes\r\n%\r\n% <<cd020_xls2TruthTable_pic04.png>>\r\n%\r\n% *Generate Model Test Harnesses* \r\n% In\r\n% more rigorous development environments it is not desirable to change the\r\n% design specification for testing. That means, _\u00e2\u20ac\u0153Don\u00e2\u20ac\u2122t add stuff to the\r\n% model just to test it!\u00e2\u20ac\ufffd_  The test harness generation will create a new\r\n% model that references the model under test. The application of the input\r\n% data and analysis of the system output data is done in the new model.\r\n% \r\n% <<cd040_makeharness_pic02.png>>\r\n% \r\n% *Generate a Report (i.e. \u00e2\u20ac\u0153Show Me the $$\u00e2\u20ac\ufffd)*\r\n% In high integrity\r\n% development processes, you haven\u00e2\u20ac\u2122t done any testing until you have\r\n% documentation that shows the results.  The CMTDTOOL provides a nice\r\n% mechanism for some basic reporting on tests of Simulink designs and\r\n% comparison of expected results versus results from the Simulink\r\n% simulation.\r\n% \r\n% <<cd060_runCMTDReport_pic08.png>>\r\n% \r\n% When engineers use Simulink to develop software specifications for flight\r\n% code in airplanes, they need to demonstrate immense amounts of\r\n% documentation that prove the designs have been tested.  Automating the\r\n% generation of the documentation certainly makes the development process\r\n% easier.\r\n\r\n%%\r\n% *Comments*\r\n%\r\n% If you would like to leave any comments regarding this post, please click \r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2930#respond here>. \r\n%\r\n% Or you can leave a comment for Yasumitsu Ito\r\n% <<https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/31609-cmtdtool#comments\r\n% here>.\r\n##### SOURCE END ##### 988266d95d9c47a4a65f5bd4b92dc10f\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n      Greg's pick this week is CMTDTOOL by Yasumitsu Ito.\r\n      \r\n   \r\n   Contents\r\n   \r\n      \r\n         Adding Test... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2011\/09\/23\/import-test-cases-from-excel-into-simulink\/\">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\/2930"}],"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=2930"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2930\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2930"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2930"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2930"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}