{"id":154,"date":"2008-09-17T15:17:07","date_gmt":"2008-09-17T20:17:07","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/2008\/09\/17\/managing-non-deployable-functions-in-a-compiled-application\/"},"modified":"2018-11-24T12:15:06","modified_gmt":"2018-11-24T17:15:06","slug":"managing-non-deployable-functions-in-a-compiled-application","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2008\/09\/17\/managing-non-deployable-functions-in-a-compiled-application\/","title":{"rendered":"Managing Non-Deployable Functions in a Compiled Application"},"content":{"rendered":"<div class=\"content\">\n<p>Guest blogger <a href=\"mailto:pwebb@mathworks.com\">Peter Webb<\/a> presents another post about building applications with the <a href=\"https:\/\/www.mathworks.com\/products\/compiler\">MATLAB Compiler<\/a>. This week's topic: understanding the types of functions that cannot be deployed and managing those that behave differently<br \/>\nwhen deployed.<\/p>\n<p>For an introduction to writing deployable code, please see the <a href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/06\/19\/writing-deployable-code\/\">June 19th post<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h3>Contents<\/h3>\n<div>\n<ul>\n<li><a href=\"#2\">Excluded Functions: Design Time Functions and GUIs<\/a><\/li>\n<li><a href=\"#3\">Unsupported Functions: Differences in the Execution Environment<\/a><\/li>\n<li><a href=\"#4\">Functions that Work Differently<\/a><\/li>\n<li><a href=\"#5\">Deploying Your Applications<\/a><\/li>\n<\/ul>\n<\/div>\n<p>When you're writing an application you intend to deploy with the MATLAB Compiler, you need to be aware that a subset of MATLAB's<br \/>\nfunctions either cannot be deployed or behave differently when deployed.<\/p>\n<p>There are two classes of non-deployable functions: functions that are not licensed for deployment; and functions that the<br \/>\ndeployment runtime (the MATLAB Common Runtime or MCR) cannot support.<\/p>\n<h3>Excluded Functions: Design Time Functions and GUIs<a name=\"2\"><\/a><\/h3>\n<p>The intent of the MATLAB Compiler and the Builders is to create a robust application with predictable behavior. In part, this<br \/>\nmeans that the users of the deployed application should not be able to modify it. Preventing users from modifying deployed<br \/>\napplications has several benefits:<\/p>\n<div>\n<ul>\n<li>Predictable performance and results: The application will always work just as it did when it was deployed.<\/li>\n<li>Easier to support: The support organization does not have to cope with user-introduced bugs.<\/li>\n<li>Protection of intellectual property: Making the code unreadable (and hence, unmodifiable) means users cannot copy the algorithms.<\/li>\n<li>Increased security: An application distributed in binary, encrypted form is more tamper-resistant than one for which the source<br \/>\ncode is available.<\/li>\n<\/ul>\n<\/div>\n<p>To prevent the modification of deployed applications, the Compiler includes only those M-files the application actually uses,<br \/>\nencrypts the M-files (this also protects the intellectual property they contain), creates MEX authorization files, and truncates<br \/>\nthe MATLAB path. But editing M-files and modifying the MATLAB path is not the only way to change a MATLAB application. Certain<br \/>\nMATLAB and toolbox functions can themselves change an application's behavior. For example, the MATLAB debugger can interactively<br \/>\nmodify the contents of variables and change the order in which the interpreter calls functions. Similarly, the figure property<br \/>\neditor can modify figure callback strings. The Compiler prevents these types of modifications by refusing to compile the functions<br \/>\nthat perform them; these functions are <i>excluded<\/i> from the generated CTF archive.<\/p>\n<p>In general the Compiler excludes those functions used when <i>developing<\/i> an application. Most of these <i>design time<\/i> functions fall into one of two categories: those that permit the application to change the way it works, like <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/dbstop.html\"><tt>dbstop<\/tt><\/a> and <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/propedit.html\"><tt>propedit<\/tt><\/a>; and those that are complete mini-applications in and of themselves, like <tt>imtool<\/tt> and <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/guide.html\"><tt>guide<\/tt><\/a>. This includes, but is not limited to:<\/p>\n<div>\n<ul>\n<li>All types of debugging functions.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li>Most of the toolbox functions ending in <tt>tool<\/tt>, such as <tt>imtool<\/tt> and <tt>sptool<\/tt>.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li>Functions that generate or edit M-code directly or indirectly; this includes, for example, the <a href=\"https:\/\/www.mathworks.com\/products\/deep-learning.html\">Deep Learning Toolbox<\/a> network training functions such as <tt>train<\/tt>.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li>Functions or GUIs that you use to <i>design<\/i> solutions, like the <a href=\"https:\/\/www.mathworks.com\/products\/database\">Database Toolbox<\/a>'s Visual Query Builder, the <a href=\"https:\/\/www.mathworks.com\/products\/curvefitting\">Curve Fitting Toolbox<\/a>'s interactive <a href=\"https:\/\/www.mathworks.com\/help\/curvefit\/curvefitting-app.html\">curvefitting tool<\/a>, and the ANFIS training algorithm used in the <a href=\"https:\/\/www.mathworks.com\/products\/fuzzylogic\">Fuzzy Logic<\/a> Toolbox. However, you typically can deploy the <i>output<\/i> of these functions: the generated database query, the M-file generated by the curve fitting tool and the fuzzy inference system trained by <a href=\"https:\/\/www.mathworks.com\/help\/fuzzy\/anfis.html\"><tt>anfis<\/tt><\/a>.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li>All functions related to <a href=\"https:\/\/www.mathworks.com\/products\/simulink\">Simulink<\/a> or <a href=\"https:\/\/www.mathworks.com\/products\/stateflow\">Stateflow<\/a>.<\/li>\n<\/ul>\n<\/div>\n<p>Many of these restrictions have no workaround: debugging functions and functions which generate M-code simply cannot be deployed.<br \/>\nThere's no workaround for the debugging functions because they are builtins, and there's no effective way to debug MATLAB<br \/>\ncode using M-files. Functions which generate M-code will not work in a deployed application because they have no way of encrypting<br \/>\nthe generated M-code, which the MCR requires. You can, of course, write your own code to compensate for other types of excluded<br \/>\nfunctions, but keep in mind that cloning MATLAB or toolbox functions violates your license agreement, which we don't encourage.<\/p>\n<p>The Compiler creates a list of excluded functions in the output directory. This list, <tt>mccExcludedFiles.log<\/tt>, which is often quite long, contains the full paths to the M-files that the Compiler removed from the list produced by <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/matlab.codetools.requiredfilesandproducts.html\"><tt>depfun<\/tt><\/a> and a short explanation for why each function cannot be deployed.<\/p>\n<p>We publish a <a href=\"https:\/\/www.mathworks.com\/products\/compiler\/compiler_support.html\">list of deployable functions<\/a>; this list may change with each release of MATLAB and the deployable toolboxes.<\/p>\n<h3>Unsupported Functions: Differences in the Execution Environment<a name=\"3\"><\/a><\/h3>\n<p>Certain MATLAB functions cannot be deployed because they act on objects that are not present in a deployed application. For<br \/>\nexample, since deployed applications have no command window, functions that modify the command window can't be deployed.<\/p>\n<p>Use of these functions in deployed application will result in <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/mlint.html\"><tt>mlint<\/tt><\/a> warnings in the MATLAB editor and runtime warnings in the deployed application. For example, calls to <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/help.html\"><tt>help<\/tt><\/a> generate this text when deployed:<\/p>\n<pre>Warning: The HELP function cannot be used in compiled applications.<\/pre>\n<p>You can prevent your deployed applications from displaying warnings like this via the <a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/toolbox\/compiler\/isdeployed.html\"><tt>isdeployed<\/tt><\/a> function. For more details, see the previous <a href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/08\/11\/path-management-in-deployed-applications\/\">blog posting<\/a> about path management in deployed applications.<\/p>\n<p>There are currently four non-deployable MATLAB functions:<\/p>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/help.html\"><tt>help<\/tt><\/a>: Deployed applications typically do not include MATLAB or toolbox help files, so there's no need for a <tt>help<\/tt> function.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/helpwin.html\"><tt>helpwin<\/tt><\/a>: <tt>helpwin<\/tt> displays help text in a new window; like <tt>help<\/tt> it is of very little use in deployed applications because deployed applications do not contain MATLAB's help files.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/keyboard.html\"><tt>keyboard<\/tt><\/a>: Since a deployed component may be part of a graphical application with no keyboard input stream, the MATLAB Compiler does<br \/>\nnot not support deployment of the <tt>keyboard<\/tt> function.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/savepath.html\"><tt>savepath<\/tt><\/a>: A deployed application's path is fixed and unchangeable, which means there's no need to save the path.<\/li>\n<\/ul>\n<\/div>\n<p>The versions of these functions that issue warnings override the versions in MATLAB because of their location in <tt>toolbox\/compiler\/deploy<\/tt> which always appears first on the path used by <a href=\"https:\/\/www.mathworks.com\/access\/helpdesk\/help\/toolbox\/compiler\/mcc.html\"><tt>mcc<\/tt><\/a> and <tt>depfun<\/tt>.<\/p>\n<h3>Functions that Work Differently<a name=\"4\"><\/a><\/h3>\n<p>Where the differences between MATLAB and the deployed environment are not insurmountable, the MATLAB Compiler and the Builder<br \/>\ntools offer versions of MATLAB functions that have been modified to work in deployed applications.<\/p>\n<p>Eight important MATLAB functions work differently in deployed applications:<\/p>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/clc.html\"><tt>clc<\/tt><\/a>: In MATLAB, <tt>clc<\/tt> clears the command window. Since deployed applications do not display a command window, <tt>clc<\/tt> clears the shell or DOS window in which the application was started.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/fopen.html\"><tt>fopen<\/tt><\/a>: In a deployed application, <tt>fopen<\/tt> looks for the specified file in the unpacked CTF archive before looking for it in the current directory. This means that<br \/>\n<tt>fopen<\/tt> will preferentially open files shipped with application, even if there's a file in the current directory with the same name.<br \/>\nNote that preferring files contained in the CTF archive is most often exactly what you want the deployed <tt>fopen<\/tt> to do. Please don't be tempted to use a full path to work around this behavior as that may create further problems when the<br \/>\napplication is deployed. For more details on why, see the previous <a href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/08\/11\/path-management-in-deployed-applications\/\">blog posting<\/a> in this series.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/home.html\"><tt>home<\/tt><\/a>: In MATLAB, <tt>home<\/tt> returns the prompt to the upper left of the command window. In a deployed application, it moves the prompt to the upper left<br \/>\nof the shell or DOS window from which the application was started. Unlike <tt>clc<\/tt>, <tt>home<\/tt> does not clear the existing text in the window.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/input.html\"><tt>input<\/tt><\/a>: The deployed version of <tt>input<\/tt> reads from the shell or DOS command window instead of the MATLAB command window. If there is no command window available,<br \/>\n<tt>input<\/tt> will hang or fail.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/loadlibrary.html\"><tt>loadlibrary<\/tt><\/a>: The version of <tt>loadlibrary<\/tt> which operates on C-style header interfaces is not available in deployed applications; but the Compiler does support <tt>loadlibrary<\/tt> with M-file prototypes.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/pause.html\"><tt>pause<\/tt><\/a>: Like <tt>input<\/tt>, <tt>pause<\/tt> (without a timeout argument) reads from the shell or DOS command window in a deployed application. If no such window is available<br \/>\n<tt>pause<\/tt> will pause forever.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/print.html\"><tt>print<\/tt><\/a>: A full accounting of the differences between printing in a deployed application and printing in MATLAB is beyond the scope<br \/>\nof this posting. While you can still use <tt>print<\/tt> for generating bitmaps or JPEGs from your figures, for hardcopy you must use <tt>deployprint<\/tt> instead. For example:<\/li>\n<\/ul>\n<\/div>\n<pre>        if isdeployed\r\n            deployprint\r\n        else\r\n            print\r\n        end<\/pre>\n<div>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/printdlg.html\"><tt>printdlg<\/tt><\/a>: Deployed applications only support the single argument version of <tt>printdlg<\/tt>, i.e., <tt>printdlg(fig)<\/tt>.<\/li>\n<\/ul>\n<\/div>\n<p>You'll find the code for the deployment-specific versions of these functions in <tt>toolbox\/compiler\/deploy<\/tt>. You can control if these functions get called in deployed applications using the <tt>isdeployed<\/tt> function. In the unlikely event that you need to change how these functions work, you can overload them by creating a function<br \/>\nof the same name in your top-level application directory. The Compiler will set the path of the generated application so that<br \/>\nyour M-file gets called instead of the one in <tt>toolbox\/compiler\/deploy<\/tt>.<\/p>\n<p>Finally, please note that functions deployed as the main routine of a standalone executable may need to process their input<br \/>\narguments differently when deployed. When making a standalone executable from a MATLAB function that takes parameters, the<br \/>\nMATLAB Compiler generates code to pass any user-supplied command line arguments to the compiled MATLAB function. However,<br \/>\nthe command line arguments are passed to the MATLAB function as strings, even if they are numeric. Therefore, any M-function<br \/>\nserving as the entry point for a compiled MATLAB program should expect (or at least test for) string input. For example:<\/p>\n<pre> function y = addten(x)\r\n   if isstr(x)\r\n       x = str2num(x);\r\n   end<\/pre>\n<pre>   y = x + 10;<\/pre>\n<h3>Deploying Your Applications<a name=\"5\"><\/a><\/h3>\n<p>Deploying your applications will be easier if you follow these guidelines:<\/p>\n<div>\n<ul>\n<li>Use <tt>isdeployed<\/tt> to protect non-deployable code from being called by deployed applications.<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li>Remember that a deployed application has no MATLAB command window (or any of the other desktop tools, like the editor).<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li>Don't change the path or rely on the current directory; deployed applications are supposed to be less flexible than MATLAB<br \/>\napplications (this makes them more secure and easier to support).<\/li>\n<\/ul>\n<\/div>\n<div>\n<ul>\n<li>Check the <a href=\"https:\/\/www.mathworks.com\/products\/compiler\/compiler_support.html\">list of deployable functions<\/a> before writing your application to make sure you can deploy the functions you plan to use.<\/li>\n<\/ul>\n<\/div>\n<p>Most of the information in this series of postings will eventually end up in the documentation for the MATLAB Compiler. Please<br \/>\ncomment on anything you feel was unclear, and ask any questions you think were unanswered. And feel free to contact me if<br \/>\nyou have other questions about the MATLAB Compiler or the Builders or post your thoughts <a href=\"https:\/\/blogs.mathworks.com\/loren\/?p=154#respond\">here<\/a>.<\/p>\n<p><script>\/\/ <![CDATA[\nfunction grabCode_d09ae640366f4e4ca5422860a69567c1() {\n        \/\/ Remember the title so we can use it in the new page\n        title = document.title;\n\n        \/\/ Break up these strings so that their presence\n        \/\/ in the Javascript doesn't mess up the search for\n        \/\/ the MATLAB code.\n        t1='d09ae640366f4e4ca5422860a69567c1 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\n        t2='##### ' + 'SOURCE END' + ' #####' + ' d09ae640366f4e4ca5422860a69567c1';\n    \n        b=document.getElementsByTagName('body')[0];\n        i1=b.innerHTML.indexOf(t1)+t1.length;\n        i2=b.innerHTML.indexOf(t2);\n \n        code_string = b.innerHTML.substring(i1, i2);\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\n\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \n        \/\/ in the XML parser.\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\n        \/\/ doesn't go ahead and substitute the less-than character. \n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\n\n        author = 'Loren Shure';\n        copyright = 'Copyright 2008 The MathWorks, Inc.';\n\n        w = window.open();\n        d = w.document;\n        d.write('\n\n\n\n<\/p>\n\n\n\n\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>\n\n\n\n\n<p>\n\n\n\n\n\\n');\n      \n      d.title = title + ' (MATLAB code)';\n      d.close();\n      }\n\/\/ ]]><\/script><\/p>\n<p style=\"text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;\"><a><span style=\"font-size: x-small; font-style: italic;\">Get<br \/>\nthe MATLAB code<br \/>\n<noscript>(requires JavaScript)<\/noscript><\/span><\/a><\/p>\n<p>Published with MATLAB\u00ae 7.6<\/p>\n<\/div>\n<p><!--\nd09ae640366f4e4ca5422860a69567c1 ##### SOURCE BEGIN #####\n%% Managing Non-Deployable Functions in a Compiled Application\n% Guest blogger <mailto:pwebb@mathworks.com Peter Webb>\n% presents another post about building applications with the\n% <https:\/\/www.mathworks.com\/products\/compiler MATLAB Compiler>.\n% This week's topic: understanding the types of functions that cannot be\n% deployed and managing those that behave differently when deployed.\n%\n% For an introduction to writing deployable code, please see the\n% <https:\/\/blogs.mathworks.com\/loren\/2008\/06\/19\/writing-deployable-code\/ % June 19th post>.\n\n%%\n% When you're writing an application you intend to deploy with the MATLAB\n% Compiler, you need to be aware that a subset of MATLAB's functions either\n% cannot be deployed or behave differently when deployed.\n%\n% There are two classes of non-deployable functions: functions that are not\n% licensed for deployment; and functions that the deployment runtime (the\n% <https:\/\/www.mathworks.com\/help\/compiler\/index.htmlf12-999353.html % MATLAB Common Runtime> or MCR) cannot support.\n%\n\n%% Excluded Functions: Design Time Functions and GUIs\n% The intent of the MATLAB Compiler and the Builders is to create a robust\n% application with predictable behavior. In part, this means that the users\n% of the deployed application should not be able to modify it. Preventing\n% users from modifying deployed applications has several benefits:\n%\n% * Predictable performance and results: The application will always work\n% just as it did when it was deployed.\n% * Easier to support: The support organization does not have to cope with\n% user-introduced bugs.\n% * Protection of intellectual property: Making the code unreadable (and\n% hence, unmodifiable) means users cannot copy the algorithms.\n% * Increased security: An application distributed in binary, encrypted\n% form is more tamper-resistant than one for which the source code is\n% available.\n%\n% To prevent the modification of deployed applications,\n% the Compiler includes only those M-files the application actually uses,\n% encrypts the M-files (this also protects the intellectual\n% property they contain), creates MEX authorization files, and truncates\n% the MATLAB path. But editing M-files\n% and modifying the MATLAB path is not the only way to change a MATLAB\n% application. Certain MATLAB and toolbox functions can themselves change\n% an application's behavior. For example, the MATLAB debugger can\n% interactively modify the contents of variables and change the order in\n% which the interpreter calls functions. Similarly, the figure property\n% editor can modify figure callback strings. The Compiler prevents these\n% types of modifications by refusing to compile the functions that perform\n% them; these functions are _excluded_ from the generated CTF archive.\n%\n% In general the Compiler excludes those functions used when _developing_\n% an application. Most of these _design time_ functions fall into one of two\n% categories: those that permit the application to change the way it works,\n% like <https:\/\/www.mathworks.com\/help\/matlab\/ref\/dbstop.html |dbstop|>\n% and\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/propedit.html % |propedit|>;\n% and those that are complete mini-applications in and of themselves, like\n% <https:\/\/www.mathworks.com\/help\/images\/index.htmlimtool.html |imtool|>\n% and <https:\/\/www.mathworks.com\/help\/matlab\/ref\/guide.html % |guide|>.\n% This includes, but is not limited to:\n%\n% * All types of debugging functions.\n%\n% * Most of the toolbox functions ending in |tool|, such as |imtool|\n% and\n% <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/toolbox\/signal\/sptool.html % |sptool|>.\n%\n% * Functions that generate or edit M-code directly or indirectly; this\n% includes, for example, the\n% <https:\/\/www.mathworks.com\/products\/deep-learning.html Deep Learning Toolbox>\n% network training functions such as\n% <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/toolbox\/nnet\/train.html % |train|>.\n%\n% * Functions or GUIs that you use to _design_ solutions, like the\n% <https:\/\/www.mathworks.com\/products\/database Database Toolbox>'s\n% <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/toolbox\/database\/ug\/f7-27388.html % Visual Query Builder>, the\n% <https:\/\/www.mathworks.com\/products\/curvefitting Curve Fitting Toolbox>'s\n% interactive <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/toolbox\/curvefit\/cftool.html curvefitting tool>,\n% and the ANFIS training algorithm used in the\n% <https:\/\/www.mathworks.com\/products\/fuzzylogic Fuzzy Logic>\n% Toolbox. However, you typically can deploy the _output_ of these\n% functions: the generated database query, the M-file generated by the\n% curve fitting tool and the\n% <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/toolbox\/fuzzy\/fp351dup8.html % fuzzy inference system> trained by\n% <https:\/\/www.mathworks.com\/help\/fuzzy\/anfis.html % |anfis|>.\n%\n% * All functions related to <https:\/\/www.mathworks.com\/products\/simulink Simulink>\n% or <https:\/\/www.mathworks.com\/products\/stateflow Stateflow>.\n%\n% Many of these restrictions have no workaround: debugging functions and\n% functions which generate M-code simply cannot be deployed. There's no\n% workaround for the debugging functions because they are builtins, and\n% there's no effective way to debug MATLAB code using M-files. Functions\n% which generate M-code will not work in a deployed application because\n% they have no way of encrypting the generated M-code, which the MCR\n% requires. You can, of course, write your own code to compensate for\n% other types of excluded functions, but keep in mind that cloning\n% MATLAB or toolbox functions violates your license agreement, which we\n% don't encourage.\n%\n% The Compiler creates a list of excluded functions in the output\n% directory. This list,\n% <https:\/\/www.mathworks.com\/help\/compiler\/index.htmlbqrvu87-6.html % |mccExcludedFiles.log|>, which is often quite long,\n% contains the full paths to the M-files that the Compiler removed from the\n% list produced by\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/matlab.codetools.requiredfilesandproducts.html % |depfun|>\n% and a short explanation for why each function cannot be deployed.\n%\n% We publish a <https:\/\/www.mathworks.com\/products\/compiler\/compiler_support.html list % of deployable functions>; this list may change with each release of MATLAB and\n% the deployable toolboxes.\n\n%% Unsupported Functions: Differences in the Execution Environment\n% Certain MATLAB functions cannot be deployed because they act\n% on objects that are not present in a deployed application. For example,\n% since deployed applications have no command window, functions that modify\n% the command window can't be deployed.\n%\n% Use of these functions in deployed application will result in\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/mlint.html % |mlint|> warnings in the MATLAB editor and runtime warnings in the\n% deployed application. For example, calls to\n% <https:\/\/www.mathworks.com\/help\/matlab\/ref\/help.html % |help|> generate this text when deployed:\n%\n%  Warning: The HELP function cannot be used in compiled applications.\n%\n% You can prevent your deployed applications from displaying warnings like\n% this via the\n% <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/toolbox\/compiler\/isdeployed.html % |isdeployed|> function. For more details, see the previous\n% <https:\/\/blogs.mathworks.com\/loren\/2008\/08\/11\/path-management-in-deployed-applications\/ % blog posting> about path management in deployed applications.\n%\n% There are currently four non-deployable MATLAB functions:\n%\n% * <https:\/\/www.mathworks.com\/help\/matlab\/ref\/help.html % |help|>: Deployed applications typically do not include MATLAB or toolbox\n% help files, so there's no need for a |help| function.\n%\n% * <https:\/\/www.mathworks.com\/help\/matlab\/ref\/helpwin.html % |helpwin|>: |helpwin| displays help text in a new window; like |help| it\n% is of very little use in deployed applications because deployed\n% applications do not contain MATLAB's help files.\n%\n% * <https:\/\/www.mathworks.com\/help\/matlab\/ref\/keyboard.html % |keyboard|>: Since a deployed component may be part of a graphical\n% application with no keyboard input stream, the MATLAB Compiler does not\n% not support deployment of the |keyboard| function.\n%\n% * <https:\/\/www.mathworks.com\/help\/matlab\/ref\/savepath.html % |savepath|>: A deployed application's path is fixed and unchangeable,\n% which means there's no need to save the path.\n%\n% The versions of these functions that issue warnings override the versions\n% in MATLAB because of their location in |toolbox\/compiler\/deploy| which\n% always appears first on the path used by\n% <https:\/\/www.mathworks.com\/access\/helpdesk\/help\/toolbox\/compiler\/mcc.html |mcc|>\n% and |depfun|.\n\n%% Functions that Work Differently\n% Where the differences between MATLAB and the deployed environment are not\n% insurmountable, the MATLAB Compiler and the Builder tools offer versions\n% of MATLAB functions that have been modified to work in deployed\n% applications.\n%\n% Eight important MATLAB functions work differently in deployed\n% applications:\n%\n% * <https:\/\/www.mathworks.com\/help\/matlab\/ref\/clc.html % |clc|>: In MATLAB, |clc| clears the command window. Since\n% deployed applications do not display a command window, |clc| clears the\n% shell or DOS window in which the application was started.\n%\n% * <https:\/\/www.mathworks.com\/help\/matlab\/ref\/fopen.html % |fopen|>: In a deployed application, |fopen| looks for the specified\n% file in the unpacked CTF archive before looking for it in the current\n% directory. This means that |fopen| will preferentially open files shipped\n% with application, even if there's a file in the current directory with\n% the same name. Note that preferring files contained in the CTF archive\n% is most often exactly what you want the deployed |fopen| to do.\n% Please don't be tempted to use a full path to work around\n% this behavior as that may create further problems when the application\n% is deployed. For more details on why, see the previous\n% <https:\/\/blogs.mathworks.com\/loren\/2008\/08\/11\/path-management-in-deployed-applications\/ % blog posting> in this series.\n%\n% * <https:\/\/www.mathworks.com\/help\/matlab\/ref\/home.html % |home|>: In MATLAB, |home| returns the prompt to the upper left of the\n% command window. In a deployed application, it moves the prompt to the\n% upper left of the shell or DOS window from which the application was\n% started. Unlike |clc|, |home| does not clear the existing text in the\n% window.\n%\n% * <https:\/\/www.mathworks.com\/help\/matlab\/ref\/input.html % |input|>: The deployed version of |input| reads from the shell or DOS\n% command window instead of the MATLAB command window. If there is no\n% command window available, |input| will hang or fail.\n%\n% * <https:\/\/www.mathworks.com\/help\/matlab\/ref\/loadlibrary.html % |loadlibrary|>: The version of |loadlibrary| which operates on C-style\n% header interfaces is not available in deployed applications; but the\n% Compiler does support |loadlibrary| with M-file prototypes.\n%\n% * <https:\/\/www.mathworks.com\/help\/matlab\/ref\/pause.html % |pause|>: Like |input|, |pause| (without a timeout argument)\n% reads from the shell or DOS command window in a deployed application. If\n% no such window is available |pause| will pause forever.\n%\n% * <https:\/\/www.mathworks.com\/help\/matlab\/ref\/print.html % |print|>: A full accounting of the differences between printing in a\n% deployed application and printing in MATLAB is beyond the scope of this\n% posting. While you can still use |print| for generating bitmaps or JPEGs\n% from your figures, for hardcopy you must use\n% <https:\/\/www.mathworks.com\/help\/compiler\/index.htmldeployprint.html % |deployprint|> instead. For example:\n%\n%          if isdeployed\n%              deployprint\n%          else\n%              print\n%          end\n%\n% * <https:\/\/www.mathworks.com\/help\/matlab\/ref\/printdlg.html % |printdlg|>: Deployed applications only support the single argument\n% version of |printdlg|, i.e., |printdlg(fig)|.\n%\n% You'll find the code for the deployment-specific versions of these\n% functions in |toolbox\/compiler\/deploy|. You can control if these functions\n% get called in deployed applications using the |isdeployed| function.\n% In the unlikely event that you need to change how these functions work,\n% you can overload them by creating a function of the same name in your\n% top-level application directory. The Compiler will set the path of the\n% generated application so that your M-file gets called instead of the one\n% in |toolbox\/compiler\/deploy|.\n%\n% Finally, please note that functions deployed as the main routine of a\n% standalone executable may need to process their input arguments\n% differently when deployed. When making a standalone executable from a\n% MATLAB function that takes parameters, the MATLAB Compiler generates code\n% to pass any user-supplied command line arguments to the compiled MATLAB\n% function. However, the command line arguments are passed to the MATLAB\n% function as strings, even if they are numeric. Therefore, any M-function\n% serving as the entry point for a compiled MATLAB program should expect\n% (or at least test for) string input. For example:\n%\n%   function y = addten(x)\n%     if isstr(x)\n%         x = str2num(x);\n%     end\n%\n%     y = x + 10;\n\n%% Deploying Your Applications\n% Deploying your applications will be easier if you follow these guidelines:\n%\n% * Use |isdeployed| to protect non-deployable code from being called by\n% deployed applications.\n%\n% * Remember that a deployed application has no MATLAB command window (or\n% any of the other desktop tools, like the editor).\n%\n% * Don't change the path or rely on the current directory; deployed\n% applications are supposed to be less flexible than MATLAB\n% applications (this makes them more secure and easier to support).\n%\n% * Check the <https:\/\/www.mathworks.com\/products\/compiler\/compiler_support.html list % of deployable functions> before writing your application to make sure you\n% can deploy the functions you plan to use.\n%\n% Most of the information in this series of postings will eventually end up\n% in the documentation for the MATLAB Compiler. Please comment on anything\n% you feel was unclear, and ask any questions you think were unanswered.\n% And feel free to contact me if you have other questions about the MATLAB\n% Compiler or the Builders or post your thoughts <https:\/\/blogs.mathworks.com\/loren\/?p=154#respond here>.\n##### SOURCE END ##### d09ae640366f4e4ca5422860a69567c1\n--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\nGuest blogger Peter Webb presents another post about building applications with the MATLAB Compiler. This week's topic: understanding the types of functions that cannot be deployed and managing... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2008\/09\/17\/managing-non-deployable-functions-in-a-compiled-application\/\">read more >><\/a><\/p>\n","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,24],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/154"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/comments?post=154"}],"version-history":[{"count":8,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/154\/revisions"}],"predecessor-version":[{"id":3156,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/154\/revisions\/3156"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}