{"id":161,"date":"2021-02-22T19:34:00","date_gmt":"2021-02-22T11:34:00","guid":{"rendered":"http:\/\/47.107.115.238\/?p=161"},"modified":"2024-08-30T19:35:27","modified_gmt":"2024-08-30T11:35:27","slug":"matlab_project","status":"publish","type":"post","link":"https:\/\/lxylp.com\/?p=161","title":{"rendered":"matlab_project"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_69_1 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/lxylp.com\/?p=161\/#matConvNet\" title=\"matConvNet\">matConvNet<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/lxylp.com\/?p=161\/#CPU_GPU_check\" title=\"CPU GPU check\">CPU GPU check<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/lxylp.com\/?p=161\/#%E7%BB%9F%E8%AE%A1%E7%9F%A9%E9%98%B5%E4%B8%AD%E6%9F%90%E5%85%83%E7%B4%A0%E7%9A%84%E4%B8%AA%E6%95%B0\" title=\"\u7edf\u8ba1\u77e9\u9635\u4e2d\u67d0\u5143\u7d20\u7684\u4e2a\u6570\">\u7edf\u8ba1\u77e9\u9635\u4e2d\u67d0\u5143\u7d20\u7684\u4e2a\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/lxylp.com\/?p=161\/#%E7%BB%99%E5%87%BD%E6%95%B0%E5%86%99%E5%B8%AE%E5%8A%A9%E6%96%87%E4%BB%B6\" title=\"\u7ed9\u51fd\u6570\u5199\u5e2e\u52a9\u6587\u4ef6\">\u7ed9\u51fd\u6570\u5199\u5e2e\u52a9\u6587\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/lxylp.com\/?p=161\/#matlab%E6%89%93%E5%8C%85%E6%88%90exe%E7%A8%8B%E5%BA%8F\" title=\"matlab\u6253\u5305\u6210exe\u7a0b\u5e8f\">matlab\u6253\u5305\u6210exe\u7a0b\u5e8f<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/lxylp.com\/?p=161\/#%E8%AE%BE%E7%BD%AE%E6%89%93%E5%8C%85%E5%8F%82%E6%95%B0\" title=\"\u8bbe\u7f6e\u6253\u5305\u53c2\u6570\">\u8bbe\u7f6e\u6253\u5305\u53c2\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/lxylp.com\/?p=161\/#%E6%89%93%E5%8C%85%E6%96%87%E4%BB%B6\" title=\"\u6253\u5305\u6587\u4ef6\">\u6253\u5305\u6587\u4ef6<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/lxylp.com\/?p=161\/#%E6%B5%8B%E8%AF%95%E7%A8%8B%E5%BA%8F\" title=\"\u6d4b\u8bd5\u7a0b\u5e8f\">\u6d4b\u8bd5\u7a0b\u5e8f<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/lxylp.com\/?p=161\/#matlab_gui%E7%BC%96%E7%A8%8B\" title=\"matlab gui\u7f16\u7a0b\">matlab gui\u7f16\u7a0b<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/lxylp.com\/?p=161\/#app%EF%BC%8CREF\" title=\"app\uff0cREF\">app\uff0cREF<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/lxylp.com\/?p=161\/#guide\" title=\"guide\">guide<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/lxylp.com\/?p=161\/#%E4%B8%8D%E5%90%8C%E5%9B%9E%E8%B0%83%E5%87%BD%E6%95%B0%E7%9A%84%E5%90%AB%E4%B9%89\" title=\"\u4e0d\u540c\u56de\u8c03\u51fd\u6570\u7684\u542b\u4e49\">\u4e0d\u540c\u56de\u8c03\u51fd\u6570\u7684\u542b\u4e49<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/lxylp.com\/?p=161\/#Callback\" title=\"Callback\">Callback<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/lxylp.com\/?p=161\/#%E5%B8%B8%E7%94%A8%E6%8E%A7%E4%BB%B6%E4%BB%A3%E7%A0%81%E6%A1%86%E6%9E%B6%E5%8F%82%E8%80%83\" title=\"\u5e38\u7528\u63a7\u4ef6\u4ee3\u7801\u6846\u67b6\u53c2\u8003\">\u5e38\u7528\u63a7\u4ef6\u4ee3\u7801\u6846\u67b6\u53c2\u8003<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/lxylp.com\/?p=161\/#%E6%80%8E%E4%B9%88%E8%8E%B7%E5%BE%97%E5%92%8C%E8%AE%BE%E7%BD%AE%E6%8E%A7%E4%BB%B6%E7%9A%84%E5%B1%9E%E6%80%A7\" title=\"\u600e\u4e48\u83b7\u5f97\u548c\u8bbe\u7f6e\u63a7\u4ef6\u7684\u5c5e\u6027\">\u600e\u4e48\u83b7\u5f97\u548c\u8bbe\u7f6e\u63a7\u4ef6\u7684\u5c5e\u6027<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/lxylp.com\/?p=161\/#%E6%95%B0%E6%8D%AE%E6%80%8E%E4%B9%88%E5%9C%A8%E4%B8%8D%E5%90%8C%E7%9A%84%E6%8E%A7%E4%BB%B6%E4%B9%8B%E9%97%B4%E4%BC%A0%E9%80%92\" title=\"\u6570\u636e\u600e\u4e48\u5728\u4e0d\u540c\u7684\u63a7\u4ef6\u4e4b\u95f4\u4f20\u9012\">\u6570\u636e\u600e\u4e48\u5728\u4e0d\u540c\u7684\u63a7\u4ef6\u4e4b\u95f4\u4f20\u9012<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/lxylp.com\/?p=161\/#%E5%9C%A8%E4%B8%8D%E5%90%8C_GUI_%E4%B9%8B%E9%97%B4%E4%BC%A0%E9%80%92%E6%95%B0%E6%8D%AE\" title=\"\u5728\u4e0d\u540c GUI \u4e4b\u95f4\u4f20\u9012\u6570\u636e\">\u5728\u4e0d\u540c GUI \u4e4b\u95f4\u4f20\u9012\u6570\u636e<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/lxylp.com\/?p=161\/#linux%E4%B8%8Bmatlab%E5%AD%97%E4%BD%93%E8%BF%87%E5%B0%8F%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95\" title=\"linux\u4e0bmatlab\u5b57\u4f53\u8fc7\u5c0f\u89e3\u51b3\u65b9\u6cd5\">linux\u4e0bmatlab\u5b57\u4f53\u8fc7\u5c0f\u89e3\u51b3\u65b9\u6cd5<\/a><\/li><\/ul><\/nav><\/div>\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"matConvNet\"><\/span>matConvNet<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>% gcc: change to 5.4 for ubuntu16.04\n% matlab: mex -setup\nsudo apt install build-essential libjpeg62-dev\n% &gt; cd &lt;MatConvNet&gt;\n% &gt; addpath matlab\n% &gt; vl_compilenn\nLD_PRELOAD=\"\/usr\/lib\/x86_64-linux-gnu\/libstdc++.so.6\" matlab<\/code><\/pre>\n\n\n\n<p>MatConvNet <a href=\"https:\/\/sites.google.com\/site\/michelevolpiresearch\/codes\/dense-labeling\">\u53c2\u8003\u6587\u732e<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"CPU_GPU_check\"><\/span>CPU GPU check<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>disp('No GPU found')\n    useGPU='no';\nend\n\n% Find number of cores\nncores=feature('numCores');\ndisp(&#91;num2str(ncores) ' cores found'])<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%BB%9F%E8%AE%A1%E7%9F%A9%E9%98%B5%E4%B8%AD%E6%9F%90%E5%85%83%E7%B4%A0%E7%9A%84%E4%B8%AA%E6%95%B0\"><\/span>\u7edf\u8ba1\u77e9\u9635\u4e2d\u67d0\u5143\u7d20\u7684\u4e2a\u6570<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>function &#91;i,temp]=pixel_num(img)   \n    % calc pixels numbers of all values\n    num_uni = unique(img);\n    pix_index=zeros(1,length(num_uni));\n    temp = zeros(1,length(num_uni));\n    for i=1:length(num_uni)\n        pix_index(1,i) = num_uni(i);\n        temp(1,i)=length(find(img==num_uni(i)));\n    end\nend<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%BB%99%E5%87%BD%E6%95%B0%E5%86%99%E5%B8%AE%E5%8A%A9%E6%96%87%E4%BB%B6\"><\/span>\u7ed9\u51fd\u6570\u5199\u5e2e\u52a9\u6587\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>unction c = addme(a,b)\n% ADDME  Add two values together.\n%   C = ADDME(A) adds A to itself.\n%\n%   C = ADDME(A,B) adds A and B together.\n%\n%   See also SUM, PLUS.\n% test random forest, rotation forest, ccf\n% \n% function demoFunc(treeN,flag,dataDir,gtDir,name_data,name_gt)\n%       Input:\n%           treeN           - number of trees\n%           flag            - 'rf','rof','ccf' for corresponding method\n%           dataDir         - remote sensing data folder\n%           gtDir           - ground truth data folder\n%           name_data       - 'name' of rs data\n%           name_gt         - 'name' of ground truth data\n% \n%       Output:\n%           none\n%       \n% copyright note\n%       author: pei liu\n%       date:   2020.7.25\nswitch nargin\n    case 2\n        c = a + b;\n        case 1\n        c = a + a;\n    otherwise\n        c = 0;\nend<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"matlab%E6%89%93%E5%8C%85%E6%88%90exe%E7%A8%8B%E5%BA%8F\"><\/span>matlab\u6253\u5305\u6210exe\u7a0b\u5e8f<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5982\u4f55\u5c06 matlab \u6e90\u4ee3\u7801\u6253\u5305\u6210 exe \u6587\u4ef6\uff0c<a href=\"https:\/\/blog.csdn.net\/u011389706\/article\/details\/79524223\">\u53c2\u8003\u6587\u732e<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%AE%BE%E7%BD%AE%E6%89%93%E5%8C%85%E5%8F%82%E6%95%B0\"><\/span>\u8bbe\u7f6e\u6253\u5305\u53c2\u6570<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u5728Matlab\u547d\u4ee4\u884c\u7a97\u53e3\u8f93\u5165\uff1adeploytool<\/p>\n\n\n\n<p>\u70b9\u51fb\u7b2c\u4e00\u9879 \u201cApplication Compiler\u201d \uff0c\u5f39\u51fa Compiler \u754c\u9762<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u6253\u5305\u6210\u7684 exe \u9700\u8981\u5728\u6709\u5bf9\u5e94 matlab \u8fd0\u884c\u73af\u5883\uff08\u6211\u7684\u662fMatlab R2016b\uff09\u7684\u7535\u8111\u4e0a\u624d\u80fd\u8fd0\u884c\u3002\u6240\u4ee5\u6839\u636e\u8fd0\u884c\u73af\u5883\u5b89\u88c5\u65b9\u5f0f\u7684\u4e0d\u540c\uff0c\u6253\u5305\u65f6\u751f\u6210\u7684\u5b89\u88c5\u7a0b\u5e8f\u5305\u62ec\u4e24\u79cd\uff1aRuntime downloaded from web\uff08\u901a\u8fc7\u7f51\u7edc\u4e0b\u8f7d\u8fd0\u884c\u73af\u5883\uff09\u548cRuntime included in package\uff08\u76f4\u63a5\u6253\u5305\u8fd0\u884c\u73af\u5883\uff09<\/li>\n\n\n\n<li>exe\u57fa\u672c\u4fe1\u606f\u8bbe\u7f6e\uff1a\u5305\u62eclogo\uff0c\u542f\u52a8\u754c\u9762\uff0c\u4f5c\u8005\uff0c\u516c\u53f8\u540d\u79f0\u7b49.<\/li>\n\n\n\n<li>\u7a0b\u5e8f\u4f9d\u8d56\u7684\u6587\u4ef6\u548c\u6587\u4ef6\u5939\uff1a\u4e00\u822c.m\u6587\u4ef6\u53ef\u4ee5\u628a\u4f9d\u8d56\u7684\u6587\u4ef6\u81ea\u52a8\u94fe\u63a5\u8fdb\u6765\uff0c\u4f46\u662f\u5bf9\u4e8e.p\u7684\u52a0\u5bc6\u6587\u4ef6\u53ca\u5176\u4ed6\u7684\u5e93\u6587\u4ef6\u9700\u8981\u624b\u52a8\u6dfb\u52a0\u3002<\/li>\n\n\n\n<li>\u5b89\u88c5\u540e\u751f\u6210\u7684\u6587\u4ef6\u53ca\u6587\u4ef6\u5939\uff1a\u53ef\u4ee5\u5728\u8fd9\u91cc\u8bbe\u7f6e\u4e00\u4e9b\u5b58\u653e\u6570\u636e\u7684\u6587\u4ef6\u5939\uff0c\u4fdd\u8bc1\u6253\u5305\u4e4b\u540e\u7684\u8def\u5f84\u6b63\u786e\u3002<\/li>\n\n\n\n<li>\u663e\u793awindows\u547d\u4ee4\u884c\u7a97\u53e3\uff1a\u8c03\u8bd5\u65f6\u4f7f\u7528\uff0c\u53ef\u4ee5\u67e5\u770b\u4e00\u4e9b\u6253\u5370\u51fa\u6765\u7684\u4fe1\u606f<\/li>\n\n\n\n<li>\u6253\u5370\u65e5\u5fd7\u6587\u4ef6\uff1a\u6253\u5370\u7a0b\u5e8f\u8f93\u51fa\u4fe1\u606f\uff0c\u4fdd\u5b58\u6210\u6587\u672c\u6587\u4ef6<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%89%93%E5%8C%85%E6%96%87%E4%BB%B6\"><\/span>\u6253\u5305\u6587\u4ef6<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u4ee5\u4e0a\u57fa\u672c\u4fe1\u606f\u8bbe\u7f6e\u5b8c\u4e4b\u540e\uff0c\u70b9\u51fb\u53f3\u4e0a\u89d2\u201cPackage\u201d\uff0c\u5f00\u59cb\u6253\u5305\u3002\u51e0\u5206\u949f\u540e\u6253\u5305\u5b8c\u6210\uff0c\u8f93\u51fa\u4e09\u4e2a\u6587\u4ef6\u5939\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>for_redistribution\uff1a\u5b89\u88c5\u7a0b\u5e8f\u548cMATLAB Runtime\u7684\u6587\u4ef6<\/li>\n\n\n\n<li>for_redistribution_files_only: \u6587\u4ef6\u5939\u5305\u542b\u5e94\u7528\u7a0b\u5e8f\u7684\u91cd\u65b0\u53d1\u5e03\u6240\u9700\u7684\u6587\u4ef6\u3002\u8fd9\u4e9b\u6587\u4ef6\u53ef\u4ee5\u5206\u53d1\u5230\u90a3\u4e9b\u6709 MATLAB \u6216\u8005\u6709 MATLAB Runtime \u7684\u7528\u6237\u7684\u7535\u8111\u4e0a<\/li>\n\n\n\n<li>for_testing: \u7a0b\u5e8f\u6d4b\u8bd5\u6587\u4ef6<\/li>\n\n\n\n<li>PackagingLog.txt\uff1a\u7f16\u8bd1\u5668\u751f\u6210\u7684\u65e5\u5fd7\u6587\u4ef6<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%B5%8B%E8%AF%95%E7%A8%8B%E5%BA%8F\"><\/span>\u6d4b\u8bd5\u7a0b\u5e8f<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u6253\u5f00\u6d4b\u8bd5\u7a0b\u5e8ffor_testing\uff0c\u627e\u5230 exe\uff0c\u8fd0\u884c\u4e4b\u540e\u6ca1\u6709\u9519\u8bef\uff0c\u5c31\u53ef\u4ee5\u5b89\u88c5\u53d1\u5e03\u4e86\u3002<\/p>\n\n\n\n<p>\u5728\u4e00\u53f0\u6ca1\u6709 matlab \u7684\u7535\u8111\u4e0a\uff0c\u5b89\u88c5for_redistribution \u4e0b\u9762\u7684\u6587\u4ef6\u3002\u5373\u540c\u65f6\u5b89\u88c5M ATLAB Runtime\u548c\u81ea\u5df1\u7684\u7a0b\u5e8f<\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/u013007900\/article\/details\/53485204\">REF1<\/a>\uff0c<a href=\"https:\/\/blog.csdn.net\/u011389706\/article\/details\/79524223\">REF2<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"matlab_gui%E7%BC%96%E7%A8%8B\"><\/span>matlab gui\u7f16\u7a0b<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"app%EF%BC%8CREF\"><\/span>app\uff0c<a href=\"https:\/\/blog.csdn.net\/tyl532667325\/article\/details\/97639089\">REF<\/a><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u5728matlab\u4e3b\u754c\u9762\u91cc\u9762\u65b0\u5efaApp\uff08\u4fdd\u5b58\u4e3aDemoApp.mlapp\uff09\uff0c\u5c31\u53ef\u4ee5\u8fdb\u5165App Designer\u3002App Designer\u7ed9\u6211\u4eec\u63d0\u4f9b\u4e86\u8bbe\u8ba1\u89c6\u56fe\u548c\u4ee3\u7801\u89c6\u56fe\u3002\u8bbe\u8ba1\u89c6\u56fe\u65b9\u4fbf\u6211\u4eec\u62d6\u653e\u5404\u79cd\u63a7\u4ef6\uff0c\u50cf\u6309\u94ae\u3001\u6587\u672c\u6846\u3001\u5750\u6807\u8f74\u554a\u4e4b\u7c7b\u3002\u4ee3\u7801\u89c6\u56fe\u662f\u7528\u6765\u7f16\u5199\u5177\u4f53\u51fd\u6570\uff0c\u6309\u94ae\u54cd\u5e94\uff0c\u4ea4\u4e92\u903b\u8f91\u4e4b\u7c7b\u3002\u8bbe\u8ba1\u89c6\u56fe\u4e0d\u7528\u8fc7\u591a\u4ecb\u7ecd\uff0c\u4e0b\u9762\u6211\u4eec\u518d\u770b\u770b\u4ee3\u7801\u89c6\u56fe\u91cc\u9762\u7684\u4e1c\u897f\u3002<\/p>\n\n\n\n<p>\u5728matlab\u4e2d\uff0c\u4e00\u4e2aapp\u5c31\u662f\u4e00\u4e2a\u7c7b\u3002\u6211\u4eec\u6253\u5f00\u4ee3\u7801\u89c6\u56fe\uff0c\u53ef\u4ee5\u770b\u5230\u8be5\u7c7b\u7ee7\u627f\u4e86matlab.apps.AppBase\uff0c\u5b83\u7684\u4e3b\u4f53\u7ed3\u6784\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>classdef DemoApp &lt; matlab.apps.AppBase\n% Properties that correspond to app components\n  properties (Access = public)\n  ....\n  end\n\n% Component initialization\n  methods (Access = private)\n\n    % Create UIFigure and components\n    function createComponents(app)\n    ....\n    end\n  end\n\n% App creation and deletion\n  methods (Access = public)\n\n% Construct app\n    function app = DemoApp\n    ...\n    end\n\n% Code that executes before app deletion\n    function delete(app)\n    ...\n    end\n  end\nend<\/code><\/pre>\n\n\n\n<p>\u4e3b\u8981\u6709\u56db\u5757<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>properties\uff1aUI\u7ec4\u5efa\u7684\u5c5e\u6027\u3002\u81ea\u52a8\u751f\u6210\uff0c\u4e0d\u5141\u8bb8\u66f4\u6539<\/li>\n\n\n\n<li>function createComponents(app)\uff1a\u521b\u5efaUI\u7ec4\u5efa\u7684\u51fd\u6570\uff0c\u81ea\u52a8\u751f\u6210\uff0c\u4e0d\u5141\u8bb8\u66f4\u6539<\/li>\n\n\n\n<li>function app = DemoApp\uff1a\u6784\u9020\u51fd\u6570\uff0c\u81ea\u52a8\u751f\u6210\uff0c\u4e0d\u5141\u8bb8\u66f4\u6539<\/li>\n\n\n\n<li>function delete(app)\uff1a\u6790\u6784\u51fd\u6570\uff0c\u81ea\u52a8\u751f\u6210\uff0c\u4e0d\u5141\u8bb8\u66f4\u6539<\/li>\n<\/ol>\n\n\n\n<p>\u6709\u4e86\u8fd9\u56db\u4e2a\u90e8\u5206\uff0capp\u7c7b\u5c31\u53ef\u4ee5\u987a\u5229\u8fd0\u884c<\/p>\n\n\n\n<p>\u5c5e\u6027\uff1a\u7c7b\u4f3c\u4e8e\u4efb\u4f55\u9762\u5411\u5bf9\u8c61\u8bed\u8a00\u7684\u6210\u5458\u53d8\u91cf\uff0c\u6211\u4eec\u53ef\u4ee5\u518d\u7c7b\u4e2d\u4efb\u4f55\u51fd\u6570\u66f4\u6539\u5c5e\u6027\u7684\u503c\u3002\u4e5f\u6709\u79c1\u6709\u548c\u516c\u5171\u4e4b\u5206<\/p>\n\n\n\n<p>\u51fd\u6570\uff1a\u8fd9\u91cc\u7684\u51fd\u6570\uff0c\u5c31\u662f\u666e\u901a\u7684\u51fd\u6570\uff0c\u4e5f\u6709\u79c1\u6709\u548c\u516c\u5171\u4e4b\u5206.<\/p>\n\n\n\n<p>\u56de\u8c03\uff1a\u56de\u8c03\u662fAppDesigner\u91cc\u9762\u6700\u91cd\u8981\u7684\u4e86\uff0c\u8fd9\u91cc\u7684\u56de\u8c03\u5c31\u76f8\u5f53\u4e8eMFC\u91cc\u9762\u7684\u54cd\u5e94\u51fd\u6570\uff0c\u5b83\u662f\u6211\u4eec\u548c\u754c\u9762\u4ea4\u4e92\u7684\u63a5\u53e3\u3002\u6bd4\u5982\u6211\u4eec\u7ed9\u6309\u94aeNextButton\u6dfb\u52a0\u4e86\u56de\u8c03ValueChangedFcn\uff0cmatlab\u4f1a\u81ea\u52a8\u7ed9\u6211\u4eec\u751f\u6210\u4e00\u4e2a\u51fd\u6570:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function NextButtonValueChanged(app, event)\nvalue = app.NextButton.Value;\nend<\/code><\/pre>\n\n\n\n<p>\u5f53\u6211\u4eec\u8fd0\u884capp\u65f6\uff0c\u70b9\u51fb\u4e86NextButton\uff0c\u5219\u4f1a\u8fdb\u5165\u8fd9\u4e2a\u51fd\u6570<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"guide\"><\/span>guide<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%B8%8D%E5%90%8C%E5%9B%9E%E8%B0%83%E5%87%BD%E6%95%B0%E7%9A%84%E5%90%AB%E4%B9%89\"><\/span>\u4e0d\u540c\u56de\u8c03\u51fd\u6570\u7684\u542b\u4e49<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Callback\"><\/span><strong>Callback<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u6700\u5e38\u7528\u7684\u5c31\u662f\u5b83\u3002\u5982\u679c\u63a7\u4ef6\u662f\u6309\u94ae\uff0c\u90a3\u70b9\u51fb\u6309\u94ae\u65f6\uff0c\u5219\u6309\u94ae\u4e0b\u7684 Callback \u5c31\u4f1a\u6267\u884c\uff1b\u5982\u679c\u662f\u6ed1\u5757\uff0c\u5219\u62d6\u52a8\u6ed1\u5757\u65f6\uff0c\u6ed1\u5757\u540d\u4e0b\u7684 callback \u5c31\u4f1a\u6267\u884c\uff1b\u603b\u4e4b\uff0c\u5c31\u662f\u5bf9\u63a7\u4ef6\u9ed8\u8ba4\u64cd\u4f5c\u65f6\uff0cmatlab \u540e\u53f0\u5c31\u4f1a\u81ea\u52a8\u8c03\u7528\u5b83\u540d\u4e0b\u7684\u7684 callback\u3002<\/p>\n\n\n\n<p><strong>CreateFcn<\/strong><\/p>\n\n\n\n<p>\u5728\u751f\u6210\u8fd9\u4e2a\u63a7\u4ef6\uff0c\u663e\u793a\u4e4b\u524d\uff0c\u6267\u884c\u4f60\u653e\u5728\u8fd9\u4e2a\u51fd\u6570\u540d\u4e0b\u7684\u4ee3\u7801<\/p>\n\n\n\n<p><strong>DeleteFcn<\/strong><\/p>\n\n\n\n<p>\u5728\u63a7\u4ef6\u8981\u9500\u6bc1\uff0c\u4f46\u662f\u88ab\u6bc1\u706d\u4e4b\u524d\u6267\u884c\u8fd9\u4e2a\u51fd\u6570\u540d\u4e0b\u7684\u4ee3\u7801\u3002\u8c8c\u4f3c\u201c\u771f\u7684\u8981\u9000\u51fa\u5417\u201d\u8fd9\u4e00\u7c7b\u5c31\u662f\u5199\u5728\u8fd9\u91cc<\/p>\n\n\n\n<p><strong>ButtonDownFcn<\/strong><\/p>\n\n\n\n<p>\u9f20\u6807\u5728\u5b83\uff08\u4ee3\u6307\u5404\u79cd\u63a7\u4ef6\uff09\u4e0a\u9762\u70b9\u51fb\u4e00\u4e0b\uff0c\u4f60\u653e\u5728\u8fd9\u4e2a\u51fd\u6570\u540d\u4e0b\u7684\u4ee3\u7801\u5c31\u4f1a\u6267\u884c\u3002\uff08ps:\u6309\u94ae\u7684callback \u4e5f\u662f\u70b9\u51fb\uff0c\u6240\u4ee5\u4f1a\u8986\u76d6\u6389\u8fd9\u4e2abuttondownfcn\u3002\uff09<\/p>\n\n\n\n<p><strong>KeyPressFcn<\/strong><\/p>\n\n\n\n<p>\u5f53\u524d\u63a7\u4ef6\u83b7\u5f97\u7126\u70b9\u4e14\u6709\u6309\u952e\u6309\u4e0b\u65f6\u6267\u884c\u3002\uff08\u4ec0\u4e48\u662f\u7126\u70b9\uff1f\u5c31\u662f\u8fd9\u4e2a\u63a7\u4ef6\u88ab\u9f20\u6807\u70b9\u4e86\uff08\u6216\u8005\u662f tab \u8f6e\u9009\u5230\u4e86\uff09\u3002\u4f60\u6253\u5f00\u4e00\u4e2a\u8bb0\u4e8b\u672c\uff0c\u7136\u540e\u518d\u70b9\u8fd9\u4e2a\u7f51\u9875\uff0c\u518d\u968f\u4fbf\u6309\u51e0\u4e2a\u6309\u952e\uff0c\u8bb0\u4e8b\u672c\u4e0a\u6709\u5b57\u4e0d\uff1f\u6ca1\u6709\u5bf9\u5427\u3002\u56e0\u4e3a\u5b83\u6ca1\u83b7\u5f97\u7126\u70b9\uff0c\u6240\u4ee5\u4f60\u7684\u6309\u952e\u5b83\u4e0d\u4f1a\u53cd\u5e94\u7684\u3002\u53ea\u6709\u4f60\u6700\u540e\u518d\u70b9\u5b83\u4e00\u4e0b\uff0c\u518d\u6309\u51e0\u4e2a\u6309\u952e\uff0c\u7ed3\u679c\u600e\u4e48\u6837\uff1f\u6709\u5b57\u4e86\u5427\uff1f\uff09\u8fd9\u91cc\u7684 KeyPressFcn \u4e5f\u662f\u4e00\u6837\u7684\u9053\u7406\u3002\u4e00\u822c\u5728\u8fd9\u4e0b\u9762\u7684\u4ee3\u7801\u8fd8\u4f1a\u5224\u65ad\u4e0b\u6309\u952e\u662f\u4ec0\u4e48\uff0c\u7136\u540e\u6267\u884c\u76f8\u5e94\u7684\u4ee3\u7801\u3002<\/p>\n\n\n\n<p><strong>SelectionChangeFcn<\/strong><\/p>\n\n\n\n<p>\u662f\u5728\u7fa4\u6309\u94ae \u7ec4\u4ef6\u4e2d\uff0c\u6539\u53d8\u9009\u62e9\u65f6\uff0c\u6240\u6267\u884c\u7684\u51fd\u6570<\/p>\n\n\n\n<p><strong>\u54ea\u4e9b\u63a7\u4ef6\u652f\u6301\u54ea\u4e9b\u56de\u8c03\u51fd\u6570<\/strong>\uff1f<\/p>\n\n\n\n<p>\u5728\u5b83\u4e0a\u9762\u53f3\u952e\u5c31\u53ef\u4ee5\u770b\u5230\u4e86\uff0c\u70b9\u8fdb\u53bb\u5c31\u53ef\u4ee5\u7f16\u8f91\u4e86\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%B8%B8%E7%94%A8%E6%8E%A7%E4%BB%B6%E4%BB%A3%E7%A0%81%E6%A1%86%E6%9E%B6%E5%8F%82%E8%80%83\"><\/span>\u5e38\u7528\u63a7\u4ef6\u4ee3\u7801\u6846\u67b6\u53c2\u8003<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>Toggle Button \u7684callback<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function   togglebutton1_callback(hObject,eventdata,handles) \n%\u8fd9\u4e00\u53e5\uff0c\u73b0\u5728\u4e0d\u7528\u7ba1\u3002\u81ea\u52a8\u52a0\u7684\u3002  \n%%%\u4ee5\u4e0b\u662f\u4e00\u822c\u4ee3\u7801\nbutton_state = get(hObject,'Value')  \n%\u63a7\u4ef6\u7532\u7684callback\u4e0b\u9762hObject\u5c31\u662f\u63a7\u4ef6\u7532\uff0c\u540c\u7406\u63a7\u4ef6\u4e59callback\u4e0b\u7684hObject......\nif button_state==get(hObject,'Max')\n    %\u5219\u600e\u4e48\u600e\u4e48\u600e\u4e48\n    else if button_state==get(hObject,'Min')\n    %\u5219\u600e\u4e48\u600e\u4e48\u600e\u4e48\nend<\/code><\/pre>\n\n\n\n<p><strong>Radio Buttons<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function \u2026\u2026\u2026\u2026\u2026\u2026\u7565\nif(get(hObject,'Value')==get(hObject,'Max'))\n  %\u88ab\u9009\u4e2d\u4e86\uff0c\u4f60\u60f3\u600e\u4e48\u6837\nelse\n %\u4e0d\u88ab\u9009\u4e2d\uff0c\u4f60\u60f3\u600e\u4e48\u6837\nend<\/code><\/pre>\n\n\n\n<p><strong>Check Boxes<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if(get(hObject,'Value')==get(hObject,'Max'))\n    %\u88ab\u9009\u4e2d\u4e86\uff0c\u4f60\u60f3\u600e\u4e48\u6837\nelse\n    %\u4e0d\u88ab\u9009\u4e2d\uff0c\u4f60\u60f3\u600e\u4e48\u6837\nend<\/code><\/pre>\n\n\n\n<p><strong>Edit Text<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function edit1_Callback(hObject,eventdata,handles)\n  user_string = get(hObject,'String');   \n  %\u5c31\u5f97\u5230\u4e86\u6240\u8f93\u5165\u7684\u5b57\u7b26\n  %\u56e0\u4e3amatlab\u662f\u628a\u6240\u6709\u7684\u8f93\u5165\u5f53\u4f5c\u5b57\u7b26\u6765\u770b\u5f85\uff0c\n  %\u5982\u679c\u4f60\u662f\u671f\u671b\u7684\u5230\u8f93\u5165\u7684\u6570\u636e\u7684\u8bdd\uff0c\u5219\uff1a\n  user_entry=str2double(get(hObject,'String'));%\u8fd9\u91cc\u8fdb\u884c\u4e00\u4e2a\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u3002\u770b\u51fd\u6570\u540d\u5c31\u77e5\u9053\u4e86\u3002\n  if isnan(user_entry)         \n  %nan\u5c31\u662fnot a number\u7684\u7b80\u5199\u3002\n  %\u77e5\u9053\u8fd9\u4e2a\u51fd\u6570\u610f\u601d\u4e86\u5427\uff1f\n  errodlg('You must entry a number value','Bad Input','modal')      \n  %\u8df3\u51fa\u4e00\u4e2a\u5bf9\u8bdd\u6846\u3002\nend\n%\u6b63\u786e\u5f97\u5230\u4e86\u6570\u503c\uff0c\u4ee5\u4e0b\u8f93\u5165\u4f60\u7684\u5176\u4ed6\u4ee3\u7801<\/code><\/pre>\n\n\n\n<p>\u9644\uff1a \u2018Bad Input\u2019\u662f\u6307\u7a97\u53e3\u6837\u5f0f\uff0c\u5c31\u50cf\u6211\u4eec\u5728\u64cd\u4f5c\u7cfb\u7edf\u4e0b\uff0c\u7ecf\u5e38\u4f1a\u8df3\u51fa\u4e00\u4e2a\u9ec4\u8272\u611f\u53f9\u53f7\u7684\u5bf9\u8bdd\u6846\uff0c\u6216\u8005\u4e00\u4e2a\u7ea2\u53c9\u7684\u5bf9\u8bdd\u6846\uff1b<\/p>\n\n\n\n<p>modal \u662f\u6307\u7a97\u53e3\u7c7b\u578b\uff0c\u5c31\u50cf\u4e00\u4e9b\u7a0b\u5e8f\u8df3\u51fa\u8b66\u544a\u5bf9\u8bdd\u6846\uff0c\u6211\u4eec\u4ec0\u4e48\u4e5f\u4e0d\u80fd\u505a\u4e86\uff0c\u53ea\u80fd\u628a\u90a3\u4e2a\u5bf9\u8bdd\u6846\u9009\u62e9\u4e00\u4e2a\u662f\u6216\u8005\u4e0d\u662f\uff0c\u624d\u80fd\u7ee7\u7eed\u505a\u5176\u4ed6\u4e8b\u60c5\u3002\u8fd9\u79cd\u5bf9\u8bdd\u6846\u5c31\u662f modal \u7c7b\u578b\u3002\u800c\u901a\u5e38\u7684\u6bd4\u5982\u6d4f\u89c8\u5668\u7684\u754c\u9762\uff0c\u6211\u4eec\u6253\u5f00\u540e\uff0c\u53ef\u4ee5\u4e0d\u7ba1\uff0c\u7136\u540e\u6253\u5f00\u522b\u7684\u5bf9\u8bdd\u6846\uff0c\u8fd9\u79cd\u5c31\u662f\u975e\u6a21\u6001\u5bf9\u8bdd\u6846\u3002<\/p>\n\n\n\n<p>\u9ed8\u8ba4\u5728\u70b9\u51fb\u4f60\u7684\u754c\u9762\u83dc\u5355\u680f\u6216\u8005\u754c\u9762\u4e0a\u7684\u5176\u4ed6\u7ec4\u4ef6\u540e\uff0c\u8fd9\u4e2a edit text \u7684 callback \u90fd\u56de\u88ab\u6267\u884c\u4e00\u904d\uff0c\u6240\u4ee5\u5728\u4f60\u70b9\u786e\u5b9a\u6309\u94ae\u7684\u65f6\u5019\uff0cedit callback \u4e0b\u8bfb\u5230\u7684\u6570\u636e\u4f1a\u66f4\u65b0\u7684\u4e86\uff0c\u4e0d\u7528\u62c5\u5fc3\uff01<\/p>\n\n\n\n<p><strong>Sliders<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function slider1_callback(hObject,eventdata,handles)\nslide_value=get(hObject,'Value');\n%\u83b7\u53d6\u6ed1\u5757\u5f53\u524d\u503c\n%\u522b\u7684\u4ee3\u7801\nend<\/code><\/pre>\n\n\n\n<p>\u9644\uff1a \u5b83\u7684Max Min \u5c5e\u6027\u8bbe\u7f6e\u4e86\u6ed1\u7aff\u7684\u6700\u5927\u6700\u5c0f\u8303\u56f4\u503c\u3002<\/p>\n\n\n\n<p><strong>List Boxes<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function ........\n  index = get(handles.listbox1,'Value');  \n  %listbox1\u662f\u4f60\u81ea\u5df1\u7684\u90a3\u4e2a\u63a7\u4ef6\u7684tag\u540d\u5b57\n  file_list =get(handles.listbox1,'String');   \n  %\u5f97\u5230\u4e86\u4f60\u7684listBoxes\u7684\u5217\u8868\n  file_name = file_list{index};\n  %\u5f97\u5230\u4e86\u6240\u9009\u62e9\u7684\u9879\u76ee\u540d\uff0c\u4e00\u4e0b\u5199\u81ea\u5df1\u7684\u4ee3\u7801\nend    <\/code><\/pre>\n\n\n\n<p>\u9644\uff1a\u6b64 callback\u5728\u9f20\u6807\u5728\u8fd9\u4e2a\u63a7\u4ef6\u4e0a\u677e\u5f00\u6216\u8005\u7279\u5b9a\u7684\u952e\u76d8\u6309\u952e\u677e\u5f00\uff08\u770b\u4f60\u600e\u4e48\u8bbe\u7f6e\u5b83\u7684\u522b\u7684\u5c5e\u6027\u7684\u4e86\uff09\u65f6\u5019\u6267\u884c\u3002<\/p>\n\n\n\n<p>\u9ed8\u8ba4\u952e\u76d8\u4e0a \u4e0b \u952e\u53ef\u4ee5\u6539\u53d8\u5b83\u7684\u503c\u540c\u65f6\u6267\u884c\u4e00\u6b21callback\u3002\u800center\u548cspace\u4e0d\u6539\u53d8\u5b83\u7684\u503c\uff0c\u53ea\u662f\u6267\u884ccallback<\/p>\n\n\n\n<p>Max-Min \u5dee\u503c\u662f0\u7684\u8bdd\uff0c\u8868\u793a\u53ea\u53ef\u4ee5\u5355\u9009\uff1b1\u7684\u8bdd\uff0c\u8868\u793a\u53ef\u4ee5\u591a\u9009\u3002\u8fd9\u4e2a\u53ef\u4ee5\u5728\u4ed6\u7684\u5c5e\u6027\u680f\u91cc\u8bbe\u7f6e<\/p>\n\n\n\n<p><strong>Pop_up Menus<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function .......\n  val=get(hObject,'Value')\n  Switch val\n    case 1\n    %\n    case 2\n    %\n    defualt\n    ......\nend<\/code><\/pre>\n\n\n\n<p><strong>Button Groups<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function .......\nswitch get(hObject,'Tag');\n%\u6ce8\u610f\u8fd9\u91cc\u7684hObject\u548c\u522b\u7684\u4e0d\u540c\uff0c\n%\u5e76\u4e0d\u662f\u6307\u8fd9\u4e2a BUtton Group ,\u800c\u662f\u6307\u5728\u7ec4\u91cc\u9762\uff0c\n%\u88ab\u9009\u4e2d\u7684\u90a3\u4e2a\u63a7\u4ef6\ncase 'radio button1'   \n%\u6309\u94ae1\u7684tag\n%\u3002\u3002\u3002\u3002\u3002\ncase '\u6309\u94ae2\u7684tag'\n%\u3002\u3002\u3002\u3002\u3002\n\u3002\u3002\u3002\nend<\/code><\/pre>\n\n\n\n<p>\u9644\uff1a\u6240\u4ee5\u5728\u8fd9\u91cc\uff0c\u5982\u679c\u8981\u62ff\u5230button groups\u672c\u8eab\u7684\u8bdd\uff0c\u5c31\u7528handles.\u5b83\u7684tag\u540d \u4e2d\u95f4\u4e00\u4e2a\u70b9\u3002<\/p>\n\n\n\n<p><strong>Axes<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>axes(handles.youraxesname);\n%\u9009\u62e9\u4f60\u7684\u4e00\u4e2aaxes\uff0c\u81ea\u7136\uff0c\u7528\u5b83\u7684tag\u6765\u9009\u4e2d\u5b83\nplot(x,y);  %\u8fd9\u65f6\uff0c\u6240\u753b\u7684\u56fe\u5c31\u5230\u5b83\u4e0a\u9762\u4e86\nset(handles.youraxesname,'XMimrFrick','on'); %\u987a\u4fbf\u8bbe\u7f6e\u4e00\u4e0b\u5b83\u7684\u5c5e\u6027\ngrid on; %\u52a0\u4e0a\u7f51\u683c<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%80%8E%E4%B9%88%E8%8E%B7%E5%BE%97%E5%92%8C%E8%AE%BE%E7%BD%AE%E6%8E%A7%E4%BB%B6%E7%9A%84%E5%B1%9E%E6%80%A7\"><\/span>\u600e\u4e48\u83b7\u5f97\u548c\u8bbe\u7f6e\u63a7\u4ef6\u7684\u5c5e\u6027<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u4fd7\u7684\u8bf4\uff0c\u5c31\u662f\u6211\u600e\u4e48\u83b7\u53d6 \u7f16\u8f91\u6846\u91cc\u7684\u5b57\u7b26\uff0c\u6ed1\u5757\u73b0\u5728\u7684\u4f4d\u7f6e\uff0cpop up\u91cc\u88ab\u9009\u4e2d\u7684\u9009\u9879\uff0c\u5982\u4f55\u63a7\u5236 static text\u663e\u793a\u6211\u8981\u6c42\u7684\u4fe1\u606f<\/p>\n\n\n\n<p>\u5728\u4f60\u9700\u8981\u7684\u5730\u65b9\u63d2\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u8bbe\u7f6e\uff1a\nset\uff08handles.\u4f60\u63a7\u4ef6\u7684tag,'\u8981\u8bbe\u7f6e\u7684\u5c5e\u6027\u540d','\u8981\u8bbe\u7f6e\u7684\u5c5e\u6027\u503c'\uff09\n\u83b7\u53d6\uff1a\nget\uff08handles.\u4f60\u63a7\u4ef6\u7684tag,'\u8981\u83b7\u53d6\u7684\u5c5e\u6027\u540d'\uff09\n\u6bd4\u5982\uff1aset(handles.edit1,'string','hello world');   <\/code><\/pre>\n\n\n\n<p>help\u91cc\u53ef\u4ee5\u770b\u5230\u6240\u6709\u53ef\u80fd\u6709\u7528\u7684\u5c5e\u6027<\/p>\n\n\n\n<p>MATLAB-&gt;Creating Graphical User Interfaces-&gt;Laying Out GUIs and Setting Properties-&gt;What Properties Do I Need to Set?<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%95%B0%E6%8D%AE%E6%80%8E%E4%B9%88%E5%9C%A8%E4%B8%8D%E5%90%8C%E7%9A%84%E6%8E%A7%E4%BB%B6%E4%B9%8B%E9%97%B4%E4%BC%A0%E9%80%92\"><\/span>\u6570\u636e\u600e\u4e48\u5728\u4e0d\u540c\u7684\u63a7\u4ef6\u4e4b\u95f4\u4f20\u9012<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u5148\u770b\u5728\u4e00\u4e2aGUI\u754c\u9762\u5185\u90e8\u7684\u4f20\u9012\u7684\u6570\u636e, \u6bcf\u4e00\u4e2a\u63a7\u4ef6\u7684\u56de\u8c03\u51fd\u6570<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function myc_Callback(hObject, eventdata, handles)  <\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f hObject\uff0c\u662f\u8ddf\u8fd9\u4e2a callback \u6240\u5173\u8054\u7684\u63a7\u4ef6\u7684 handles\uff0c\u5728\u5b83\u81ea\u5df1\u7684 callback \u4e0b\uff0c\u53ef\u4ee5\u7528\u4ee3\u53f7-> hObject \u6765\u8c03\u7528\u5b83\u3002\u3002\u4e0d\u7528\u7ba1\u90a3\u4e48\u9ebb\u70e6\u7684\u6982\u5ff5\uff0c\u53ea\u7528\u77e5\u9053\uff0c\u63a7\u4ef6\u81ea\u5df1\u7684\u56de\u8c03\u51fd\u6570\u8c03\u7528\u81ea\u5df1\u7684\u5c5e\u6027\uff0c\u53ea\u7528 hObject.\u5c5e\u6027\u540d \u5c31\u53ef\u4ee5\u4e86\uff08\u4e2d\u95f4\u4e00\u70b9\uff09\u3002<\/li>\n\n\n\n<li>\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662fMATLAB\u7684\u4fdd\u7559\u53c2\u6570<\/li>\n\n\n\n<li>\u7b2c\u4e09\u4e2ahandles\uff0c\u662f\u8fd9\u4e2aGUI\u754c\u9762\u7684\u4ee3\u53f7\u3002\u53ef\u4ee5\u901a\u8fc7\u5b83\u83b7\u53d6\u8fd9\u4e2a\u754c\u9762\u7684\u6240\u6709\u4fe1\u606f\u3002\u6240\u4ee5\u5728\u63a7\u4ef6A\u81ea\u5df1\u7684\u56de\u8c03\u51fd\u6570\u4e2d\uff0c\u8981\u83b7\u53d6\u6216\u8005\u8bbe\u7f6e\u522b\u7684\u63a7\u4ef6\u7684\u5c5e\u6027\uff0c\u5c31\u7528 handles.\u522b\u7684\u63a7\u4ef6Tag.\u5c5e\u6027<\/li>\n<\/ol>\n\n\n\n<p>handles hObject \u90fd\u662f\u7ed3\u6784\u4f53\u3002\u6b63\u5e38\u7684\u7f16\u7a0b\u6982\u5ff5\u3002<\/p>\n\n\n\n<p>handles \u683c\u5f0f\u662f\u4e00\u4e2a\u5b58\u653e\u6570\u636e\u7684\u7f38\u3002\u63a7\u4ef6\u7684 handles \u662f\u5c0f\u7f38\uff0c\u5b83\u7684\u540d\u5b57\u53eb\u505a hObject\uff1bGUI \u754c\u9762\u7684 handle \u662f\u4e00\u4e2a\u5927\u7f38\uff0c\u5e76\u4e14\u8fd9\u4e2a\u7f38\u540d\u5b57\u4e5f\u53eb\u505a handles\uff1b\u5927\u7f38\u91cc\u5b58\u653e\u4e86\u6240\u6709\u7684\u5c0f\u7f38\u548c\u6240\u6709\u7528\u6237\u6570\u636e\uff0c\u4f60\u53ea\u9700 handles.\u63a7\u4ef6 A \u7684 tag \u5c31\u53ef\u4ee5\u5b58\u53d6\u63a7\u4ef6A\u7684\u4fe1\u606f\u3002<\/p>\n\n\n\n<p>\u90a3\u6211\u600e\u4e48\u628a\u81ea\u5df1\u8ba1\u7b97\u51fa\u6216\u8005\u522b\u7684\u4ec0\u4e48\u6570\u636e\u653e\u5230\u8fd9\u4e2a\u7f38\u91cc\u5462\uff1f<\/p>\n\n\n\n<p>\u5728\u4efb\u4f55\u5730\u65b9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>handles.\u81ea\u5df1\u7684\u53d8\u91cf\u540d = \u67d0\u4e9b\u503c     \n%\uff08\u5176\u5b9e\u4e5f\u5c31\u662f\u7ed9\u7ed3\u6784\u4f53\u6dfb\u52a0\u6210\u5458\u53d8\u91cf\uff09\n% \u8fd9\u6837\u4f60\u5c31\u5b9a\u4e49\u4e86\u81ea\u5df1\u7684\u53d8\u91cf\u3002    <\/code><\/pre>\n\n\n\n<p>\u5728\u4efb\u4f55\u5730\u65b9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>b=handles.\u81ea\u5df1\u7684\u53d8\u91cf\u540d     \n% \uff08\u7ed3\u6784\u540d\u52a0\u70b9\u53f7\u6765\u5f15\u7528\u6210\u5458\u53d8\u91cf\uff09\n% \u5c31\u53ef\u4ee5\u5f97\u5230\u8fd9\u4e2a\u53d8\u91cf\u503c\uff0c\u540c\u6837\u4e5f\u53ef\u4ee5\u4fee\u6539\u5b83\u3002 <\/code><\/pre>\n\n\n\n<p>\u522b\u5fd8\u4e86\u4f7f\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>guidata(hObject, handles);\n% \u5728\u51fd\u6570\u672b\u5c3e\u6765\u4fdd\u5b58\u4f60\u5bf9handles\u548chObject\u7684\u64cd\u4f5c\u3002\n% \uff08\u4e0d\u7136\u4f60\u81ea\u5b9a\u4e49\u7684\u53d8\u91cf\u5c31\u6ca1\u4e86\uff09<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%9C%A8%E4%B8%8D%E5%90%8C_GUI_%E4%B9%8B%E9%97%B4%E4%BC%A0%E9%80%92%E6%95%B0%E6%8D%AE\"><\/span>\u5728\u4e0d\u540c GUI \u4e4b\u95f4\u4f20\u9012\u6570\u636e<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u8fd9\u90e8\u5206\u662f\u4ee5\u524d\u5199\u7684\u6211\u53d1\u73b0\u6211\u7684\u7406\u89e3\u6709\u4e9b\u95ee\u9898\u2014\u6240\u4ee5\u6211\u73b0\u5728\u4f20\u9012\u6570\u636e\u7528\u7684application data\u7684\u65b9\u6cd5\uff0c\u6ca1\u7528\u8fd9\u4e2a-\u3002\u53ef\u80fd\u8fd8\u6ca1\u7406\u89e3\u900foutput\u7684\u51fd\u6570\u4f5c\u7528<\/p>\n\n\n\n<p><strong>\u4f20\u5165<\/strong><\/p>\n\n\n\n<p>\u770b\u6253\u5f00\u4e00\u4e2aGUI\u754c\u9762\u65f6\uff0c\u4f20\u7ed9\u4ed6\u7684\u53c2\u6570\u6709\u54ea\u4e9b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function mygui_OpeningFcn(hObject, eventdata, handles, varargin)\n%\u6240\u6709\u7684\u542f\u52a8\u53c2\u6570\u90fd\u662f\u901a\u8fc7varargin\u4f20\u5230\u5b83\u7684OpeningFcn\u91cc\u9762\u7684\u3002<\/code><\/pre>\n\n\n\n<p>\u90a3\u542f\u52a8\u53c2\u6570\u53ef\u4ee5\u662f\u54ea\u4e9b\u5462\uff1f<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>figure\uff0c\u4e5f\u5c31\u662f\u7a97\u53e3\u53c2\u6570<br>\u6bd4\u5982\u8bf4position\u4e4b\u7c7b<br>\u4f8b\u5982\uff1a\u6253\u5f00\u8fd9\u4e2a GUI \u65f6\uff0c\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4 mygui(\u2018Position\u2019,[434 234 234 34])\u5219\u8868\u793a\u6253\u5f00\u7a97\u53e3\u5728\u8fd9\u4e2a\u4f4d\u7f6e\uff1b\u8fd8\u6709\u54ea\u4e9b\u53ef\u63a7\u5c5e\u6027\u53ef\u4ee5\u67e5help\u3002<\/li>\n\n\n\n<li>\u81ea\u5b9a\u4e49\u53c2\u6570<br>\u5982\u679c\u4f20\u5165\u7684\u53c2\u6570\u4e0d\u662ffigure\u7684\u5c5e\u6027\uff08matlab\u67e5\u627e\u4e0d\u5230\u4f60\u8f93\u5165\u7684\u5c5e\u6027\u540d\uff09\uff0c\u5219\u4f60\u8f93\u5165\u7684\u53c2\u6570\u4f5c\u4e3a\u4e00\u4e2a\u5411\u91cf\u5b58\u653e\u5728varargin\u91cc\u9762\u3002<br>\u6bd4\u5982mygui(\u2018\u8def\u4eba\u7532\u2019,\u201980\u2018\uff09\uff0c\u90a3varargin{1}\u5b58\u653e\u4e86\u2019\u8def\u4eba\u7532\u2019\uff0cvarargin{2}=\u201980\u2018<br>\u90a3mygui\u4e2d\u5bf9\u8fd9\u8bfb\u53d6\u4e24\u4e2a\u6570\u636e\u8fdb\u884c\u53cd\u5e94\uff0c\u5c31\u8fbe\u5230\u4e86\u4f20\u5165\u53c2\u6570\u7684\u76ee\u7684\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u4f20\u51fa<\/strong><\/p>\n\n\n\n<p>\u90a3\u600e\u4e48\u628a\u6570\u636e\u4f20\u51fa\u6765\u5462\uff1f<\/p>\n\n\n\n<p>\u5c06\u4f60\u8981\u8f93\u51fa\u7684\u6570\u636e\u5b58\u5728handles.output\u91cc\u9762<\/p>\n\n\n\n<p>\u5728GUI\u4efb\u610f\u5730\u65b9<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>handles.output=\u6570\u636e1\uff1b\nhandles.secend_output=\u6570\u636e2\uff1b    \n\n\u7136\u540e\u5728GUI\u7684outputFcn\u91cc\u9762\u52a0\u4e0a\n\nvaraginout{1}=handles.output;\nvaraginout{2}=handles.secend_output;  <\/code><\/pre>\n\n\n\n<p>\u8fd9\u6837\u5c31\u628a\u6570\u636e\u4f20\u51fa\u6765\u4e86\u3002<a href=\"http:\/\/blog.sina.com.cn\/s\/blog_50363a790102wr6s.html\">REF<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"linux%E4%B8%8Bmatlab%E5%AD%97%E4%BD%93%E8%BF%87%E5%B0%8F%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95\"><\/span>linux\u4e0bmatlab\u5b57\u4f53\u8fc7\u5c0f\u89e3\u51b3\u65b9\u6cd5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Tuning a high-DPI Linux system requires two steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Setting the MATLAB scale factor<\/li>\n\n\n\n<li>Calibrating the system\u2019s DPI<\/li>\n<\/ul>\n\n\n\n<p>The MATLAB scale factor affects MATLAB desktop and the size\/position of windows. The system DPI determines the scale and font size of axes and labels. To set the MATLAB scale factor, please use the following MATLAB commands:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&gt;&gt; s = settings;s.matlab.desktop.DisplayScaleFactor\n&gt;&gt; s.matlab.desktop.DisplayScaleFactor.PersonalValue = 1.5<\/code><\/pre>\n\n\n\n<p>To calibrate the system DPI to match the scale facto, please use the following terminal commands :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>u@T470:~<span class=\"katex math inline\">xdpyinfo | grep resolution\n    resolution:    96x96 dots per inch\nu@T470:~<\/span> xrandr --dpi 144<\/code><\/pre>\n\n\n\n<p>The DPI value chosen should be the resolution found with xdpyinfo multiplied by the MATLAB scale factor that was set. In the example, 96*1.5 = 144.<\/p>\n\n\n\n<p>MATLAB must be restarted after Step 2.<\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/zwhut\/article\/details\/79779174\">REF<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>matConvNet MatCo&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[13],"class_list":["post-161","post","type-post","status-publish","format-standard","hentry","category-linux","tag-13"],"_links":{"self":[{"href":"https:\/\/lxylp.com\/index.php?rest_route=\/wp\/v2\/posts\/161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lxylp.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lxylp.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lxylp.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lxylp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=161"}],"version-history":[{"count":1,"href":"https:\/\/lxylp.com\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions"}],"predecessor-version":[{"id":162,"href":"https:\/\/lxylp.com\/index.php?rest_route=\/wp\/v2\/posts\/161\/revisions\/162"}],"wp:attachment":[{"href":"https:\/\/lxylp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lxylp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lxylp.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}