{"id":4920,"date":"2013-11-22T09:00:44","date_gmt":"2013-11-22T14:00:44","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=4920"},"modified":"2017-01-06T21:36:33","modified_gmt":"2017-01-07T02:36:33","slug":"automatically-build-matlab-apps","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2013\/11\/22\/automatically-build-matlab-apps\/","title":{"rendered":"Automatically build MATLAB apps"},"content":{"rendered":"\r\n<div class=\"content\"><p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\">Jiro<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/43832-app-builder-for-simbiology-models\">App Builder for SimBiology Models<\/a> by my colleague <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/71047\">Asawari Samant<\/a>.<\/p><p>MATLAB is a scientific software for solving engineering and scientific problems. You can interactively explore your data and apply sophisticated analysis routines to get insights and draw conclusions. Sometimes, you may want to provide those analytical capabilities to other people you work with, but they may not be as familiar with MATLAB as you are. Or, they may not be interested in freely exploring their data, but they would like to be able to apply the specific analysis routines you developed for the problem. In such cases, it's often useful to provide them with a nice user interface around the functionality you built.<\/p><p>With MATLAB, you can create <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/guide-or-matlab-functions.html\">user interfaces<\/a> for your program.\r\n\r\n<\/p><p>But what's different about this app from other MATLAB apps? Well, this was \"automatically\" created based on a number of parameters.<\/p><p>This entry by Asawari is specifically for users doing <a href=\"http:\/\/en.wikipedia.org\/wiki\/PK\/PD_models\">PK\/PD<\/a> and <a href=\"http:\/\/en.wikipedia.org\/wiki\/Systems_biology\">systems biology<\/a> modeling using <a href=\"https:\/\/www.mathworks.com\/products\/simbiology\/\">SimBiology<\/a>, but a similar framework can be applied to other applications. The basic idea is to create a structure of parameters that defines the SimBiology model that it's connected to, the input parameters that you would like your app to be able to control, the output parameters you want to monitor, and any other parameters that are relevant for the app.<\/p><pre class=\"codeinput\"><span class=\"comment\">% Project and model information<\/span>\r\nxin.projectName = <span class=\"string\">'Tumor_Growth'<\/span>;       <span class=\"comment\">% project name<\/span>\r\nxin.modelName = <span class=\"string\">'Monotherapy'<\/span>;          <span class=\"comment\">% model name<\/span>\r\n\r\n<span class=\"comment\">% Inputs and ranges<\/span>\r\nxin.inputs  = {<span class=\"comment\">% Name, Lower Bound, Upper Bound<\/span>\r\n               <span class=\"string\">'L0'<\/span>  0    20;\r\n               <span class=\"string\">'L1'<\/span>  0    10;\r\n               <span class=\"string\">'w0'<\/span>  0    10;\r\n               <span class=\"string\">'k1'<\/span>  0    20;\r\n               <span class=\"string\">'k2'<\/span>  0    10;\r\n               <span class=\"string\">'ke'<\/span>  0    10;\r\n               <span class=\"string\">'x1'<\/span>  0    10;\r\n               <span class=\"string\">'x2'<\/span>  0    20;\r\n               <span class=\"string\">'ka'<\/span>  0    100;\r\n               <span class=\"string\">'Central'<\/span>  0    10;};    <span class=\"comment\">% sliders ranges<\/span>\r\n\r\n<span class=\"comment\">% Specify output<\/span>\r\nxin.outputNames = {<span class=\"comment\">% Name , Scope;<\/span>\r\n                   <span class=\"string\">'w'<\/span>, <span class=\"string\">''<\/span>};            <span class=\"comment\">% Name and Scope<\/span>\r\n\r\n<span class=\"comment\">% Specify time &amp; time units<\/span>\r\nxin.timeUnits = <span class=\"string\">'day'<\/span>;                  <span class=\"comment\">% stop time units<\/span>\r\nxin.stopTime = 30;                      <span class=\"comment\">% stop time<\/span>\r\n\r\n<span class=\"comment\">% Specify dose properties<\/span>\r\nxin.doses = <span class=\"string\">'IV Dose'<\/span>;                  <span class=\"comment\">% doses<\/span>\r\n\r\n<span class=\"comment\">% Specify name of image file with model schematic<\/span>\r\nxin.imageFilename = <span class=\"string\">'tumorModel.png'<\/span>;   <span class=\"comment\">% model schematic<\/span>\r\n\r\n<span class=\"comment\">% Specify name of the app<\/span>\r\nxin.appName = <span class=\"string\">'Model Exploration: Tumor Growth'<\/span>;\r\n<\/pre><p>Once those parameters are set, you simply call <tt>buildApp<\/tt> to create the app.<\/p><pre class=\"codeinput\">buildApp(xin, 0)\r\n<\/pre><p>This framework works really well for this application, because the task of varying parameters and simulating the model is a very common use case in PK\/PD modeling. Well, it's common for any kind of modeling for that matter. However, creating a custom app for different models, with different number of parameters, can be a tedious task. Asawari's entry makes this an automated process.<\/p><p>In the entry, Asawari includes several examples that show how one can use the app builder. Note that you need <a href=\"https:\/\/www.mathworks.com\/products\/simbiology\/\">SimBiology<\/a> and <a href=\"https:\/\/www.mathworks.com\/products\/statistics\/\">Statistics Toolbox<\/a> to run this. If you want to create standalone apps, you also need <a href=\"https:\/\/www.mathworks.com\/products\/compiler\/\">MATLAB Compiler<\/a>.<\/p><p><b>Comments<\/b><\/p><p>If you're doing PK\/PD or systems biology modeling with SimBiology, you should definitely check this out. Be sure to let Asawari know <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/43832-app-builder-for-simbiology-models#comments\">what you think<\/a>. Also, let us know how you create and distribute MATLAB apps to your colleagues, by leaving us a comment <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=4920#respond\">here<\/a>.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_e75da863b72741a88410678841bfdc86() {\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='e75da863b72741a88410678841bfdc86 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' e75da863b72741a88410678841bfdc86';\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        copyright = 'Copyright 2013 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 copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\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     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_e75da863b72741a88410678841bfdc86()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2013b<br><\/p><p class=\"footer\"><br>\r\n      Published with MATLAB&reg; R2013b<br><\/p><\/div><!--\r\ne75da863b72741a88410678841bfdc86 ##### SOURCE BEGIN #####\r\n%%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/15007\r\n% Jiro>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/43832-app-builder-for-simbiology-models App Builder\r\n% for SimBiology Models> by my colleague\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/71047\r\n% Asawari Samant>.\r\n%\r\n% MATLAB is a scientific software for solving engineering and scientific\r\n% problems. You can interactively explore your data and apply sophisticated\r\n% analysis routines to get insights and draw conclusions. Sometimes, you\r\n% may want to provide those analytical capabilities to other people you\r\n% work with, but they may not be as familiar with MATLAB as you are. Or,\r\n% they may not be interested in freely exploring their data, but they would\r\n% like to be able to apply the specific analysis routines you developed for\r\n% the problem. In such cases, it's often useful to provide them with a nice\r\n% user interface around the functionality you built.\r\n%\r\n% With MATLAB, you can create\r\n% <https:\/\/www.mathworks.com\/help\/matlab\/guide-or-matlab-functions.html user\r\n% interfaces> for your program, like the one shown below.\r\n%\r\n% <html>\r\n% <img\r\n% src=\"https:\/\/www.mathworks.com\/matlabcentral\/fx_files\/43832\/1\/TurmorGrowthApp.png\" width=600>\r\n% <\/html>\r\n%\r\n% But what's different about this app from other MATLAB apps? Well, this\r\n% was \"automatically\" created based on a number of parameters.\r\n%\r\n% This entry by Asawari is specifically for users doing\r\n% <http:\/\/en.wikipedia.org\/wiki\/PK\/PD_models PK\/PD> and\r\n% <http:\/\/en.wikipedia.org\/wiki\/Systems_biology systems biology> modeling\r\n% using <https:\/\/www.mathworks.com\/products\/simbiology\/ SimBiology>, but a\r\n% similar framework can be applied to other applications. The basic idea is\r\n% to create a structure of parameters that defines the SimBiology model\r\n% that it's connected to, the input parameters that you would like your app\r\n% to be able to control, the output parameters you want to monitor, and any\r\n% other parameters that are relevant for the app.\r\n\r\n% Project and model information\r\nxin.projectName = 'Tumor_Growth';       % project name\r\nxin.modelName = 'Monotherapy';          % model name\r\n\r\n% Inputs and ranges\r\nxin.inputs  = {% Name, Lower Bound, Upper Bound\r\n               'L0'  0    20;\r\n               'L1'  0    10;\r\n               'w0'  0    10;\r\n               'k1'  0    20;\r\n               'k2'  0    10;\r\n               'ke'  0    10;\r\n               'x1'  0    10;\r\n               'x2'  0    20;\r\n               'ka'  0    100;\r\n               'Central'  0    10;};    % sliders ranges\r\n\r\n% Specify output\r\nxin.outputNames = {% Name , Scope;\r\n                   'w', ''};            % Name and Scope\r\n\r\n% Specify time & time units\r\nxin.timeUnits = 'day';                  % stop time units\r\nxin.stopTime = 30;                      % stop time\r\n\r\n% Specify dose properties\r\nxin.doses = 'IV Dose';                  % doses\r\n\r\n% Specify name of image file with model schematic\r\nxin.imageFilename = 'tumorModel.png';   % model schematic\r\n\r\n% Specify name of the app\r\nxin.appName = 'Model Exploration: Tumor Growth';\r\n\r\n%%\r\n% Once those parameters are set, you simply call |buildApp| to create the\r\n% app.\r\n\r\nbuildApp(xin, 0)\r\n\r\n%%\r\n% This framework works really well for this application, because the task\r\n% of varying parameters and simulating the model is a very common use case\r\n% in PK\/PD modeling. Well, it's common for any kind of modeling for that\r\n% matter. However, creating a custom app for different models, with different\r\n% number of parameters, can be a tedious task. Asawari's entry makes this\r\n% an automated process.\r\n%\r\n% In the entry, Asawari includes several examples that show how one can use\r\n% the app builder. Note that you need\r\n% <https:\/\/www.mathworks.com\/products\/simbiology\/ SimBiology> and\r\n% <https:\/\/www.mathworks.com\/products\/statistics\/ Statistics Toolbox> to run\r\n% this. If you want to create standalone apps, you also need\r\n% <https:\/\/www.mathworks.com\/products\/compiler\/ MATLAB Compiler>.\r\n%\r\n% *Comments*\r\n%\r\n% If you're doing PK\/PD or systems biology modeling with SimBiology, you\r\n% should definitely check this out. Be sure to let Asawari know\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/43832-app-builder-for-simbiology-models#comments what\r\n% you think>. Also, let us know how you create and distribute MATLAB apps\r\n% to your colleagues, by leaving us a comment\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=4920#respond here>.\r\n\r\n##### SOURCE END ##### e75da863b72741a88410678841bfdc86\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\nJiro's pick this week is App Builder for SimBiology Models by my colleague Asawari Samant.MATLAB is a scientific software for solving engineering and scientific problems. You can interactively... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2013\/11\/22\/automatically-build-matlab-apps\/\">read more >><\/a><\/p>","protected":false},"author":35,"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\/4920"}],"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\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=4920"}],"version-history":[{"count":9,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/4920\/revisions"}],"predecessor-version":[{"id":8350,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/4920\/revisions\/8350"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=4920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=4920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=4920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}