【文章內(nèi)容簡介】
14 回調(diào)函數(shù)別寫好后, 在設(shè)計面板中選擇? run?命令, MATLAB 會自動調(diào)用程序代碼,調(diào)試成功后,通過選擇按鈕,即可實現(xiàn)對應(yīng)函數(shù)的調(diào)用和執(zhí)行。程序執(zhí)行后的狀態(tài)如圖 35 所示。 圖 35 運行后的燈光控制系統(tǒng)界面 智能家居 控制系統(tǒng)界面的設(shè)計 智能家居系統(tǒng)包括八個子系統(tǒng),即燈光控制系統(tǒng)、遠程監(jiān)控系統(tǒng)、可視對講系統(tǒng)、門禁控制系統(tǒng)、安防報警系統(tǒng)、家電控制系統(tǒng)、 窗簾控制系統(tǒng)和背景音樂系統(tǒng)。智能家居系統(tǒng)主界面如圖 36 所示。本文中的智能家居系統(tǒng)客戶端界面將這些子系統(tǒng)集成在一起,通過調(diào)用不同按鈕的回調(diào)函數(shù)可進入各子系統(tǒng)的控制界面。比如調(diào)用燈光控制系統(tǒng),可在其按鈕的回調(diào)函數(shù)中寫入以下代碼: untitled1。 %調(diào)用 。 set (untitled2,39。visible39。,39。off39。)。 %不顯示智能家居系統(tǒng)界面。 15 set (untitled1,39。visible39。,39。on39。)。 %顯示燈光控制系統(tǒng)界 面。 若要求退出子系統(tǒng)時返回智能家居系統(tǒng)主界面,則可在各子系統(tǒng)的退出按鈕的回調(diào)函數(shù)中的 case‘是’后加入以下代碼: set (untitled2,39。visible39。,39。on39。)。 %顯示智能家居系統(tǒng)主界面。 set (untitled1,39。visible39。,39。off39。)。 %不顯示燈光控制系統(tǒng)界面。 圖 36 智能家居控制系統(tǒng)的界面 將 MATLAB GUI 程序轉(zhuǎn)換成可執(zhí)行的程序 對于一個通用的,比較成熟的解決方案,當(dāng)然期望它能應(yīng)用到更多的場合,而 .exe(可 執(zhí)行)文件可運行于所有的通用 Windows 操作系統(tǒng)。因此,將 M 文件轉(zhuǎn)換成 .exe 文件會使用戶使用起來更加方便,加強了應(yīng)用程序的通用性。在此我們將 和 生成 .exe 文件。 16 在確定安裝好 Matlab Compiler 后,還需要對 Compiler 進行適當(dāng)?shù)呐渲?,方法是?Matlab 命令窗口輸入: Mbuild –setup。按提示選擇編譯器。進行操作的信息如下: mbuild setup Please choose your piler for building standalone MATLAB applications: Would you like mbuild to locate installed pilers [y]/n? y Select a piler: [1] Microsoft Visual C++ 2021 Express in C:\Program Files (x86)\Microsoft Visual Studio [0] None Compiler: 1 Please verify your choices: Compiler: Microsoft Visual C++ 2021 Express Location: C:\Program Files (x86)\Microsoft Visual Studio Are these correct [y]/n? y **************************************************************************** Warning: Applications/ponents generated using Microsoft Visual C++ 2021 require that the Microsoft Visual Studio 2021 runtime libraries be available on the puter used for deployment. To redistribute your applications/ponents, be sure that the deployment machine has these runtime libraries. 17 **************************************************************************** Trying :C:\Users\asus\AppData\Roaming\MathWorks\MATLAB\R2021b\co From template: D:\matlab\bin\win64\mbuildopts\ Done . . . 將已有的 和 單獨放在一個文件夾中,然后打開 MATLAB, 選擇路徑為此文件夾,然后在命令窗口輸入: mcc m untitled1 等待即可將 GUI 程序轉(zhuǎn)換成可執(zhí)行程序。在此路徑下生成, , , , , 。其中: , 為脫離 matlab 環(huán)境運行必需的文件。有了 , 兩個文件就可以 在未安裝 matlab 的機器上運行客戶端圖形界面。 第四章 總結(jié) 總結(jié) 經(jīng)過本系統(tǒng)設(shè)計學(xué)到了很多東西,設(shè)計過程也是一個知識快速增長的過程,對不會的知識及時和老師交流、查閱資料,以解決設(shè)計過程中遇到的問題。本論文最困難的是回調(diào)函數(shù)的設(shè)計,在回調(diào)函數(shù)的設(shè)計過程中經(jīng)常達不到預(yù)期的目標(biāo),最終在指導(dǎo)老師的幫助下順利的完成了預(yù)定的目標(biāo)。 這次畢業(yè)設(shè)計,感受最 深的是經(jīng)過自己的努力和老師、同學(xué)的幫助,我學(xué)習(xí)到了很多知識,認識的自己知識的欠缺,有時候遇到問題,分析 18 問題不夠透徹,使我在設(shè)計的過程中走了很多彎路,不過及時和老師溝通和同學(xué)交流,都能分析到問題的根本所在;因此我覺得在今后的學(xué)習(xí)過程中,認識問題、分析問題很重要,這樣能夠及時解決問題,使自己有更多的時間學(xué)習(xí)更多的知識。 根據(jù)設(shè)計要求,本文完成的工作有: (1) 詳細設(shè)計了燈光控制系統(tǒng)客戶端的圖形用戶界面,使得對燈光系統(tǒng)的控制可視化。 (2) 考慮到燈光控制系統(tǒng)只是智能家居系統(tǒng)的一個子系統(tǒng),設(shè)計了一個智能家居系統(tǒng) 圖形用戶界面,集成了八個子系統(tǒng)。通過點擊不同按鈕可調(diào)用不同子系統(tǒng)的圖形用戶界面。 19 ※※※※※ 致 謝 本論文是在周鵬教授的親自指導(dǎo)下成功完成的。通過和周老師多次交流,我深深的感覺到周老師知識廣博、治學(xué)嚴(yán)謹、細致認真,經(jīng)常指導(dǎo)和給我們意見,對論文要求嚴(yán)格。對于我請教的問題,耐心細致解答,在此衷心感謝周老師在我設(shè)計課題的過程中,悉心的指導(dǎo)和幫助。 同時我要感謝我的同學(xué),在本次設(shè)計工作中,他們給予我了很多專業(yè)性的幫助。不僅如此,他們在學(xué)習(xí)過程中堅定的毅力以及不怕困難,勇于挑戰(zhàn)的精神都 是我應(yīng)該努力的方向。 最后 感謝我的家人對我一如既往的關(guān)懷和鼓勵。他們教了我很多做人的道理以及踏實實干的精神。在精神和物質(zhì)上都給予了我最大的支持,使我能夠更加積極地面對學(xué)習(xí)和生活中的困難,勇于進取。 20 參考文獻 [1] 陳垚光 . 精通 MATLAB GUI 設(shè)計 [M].北京 : 電子工業(yè)出版社 , 2021. [2] 董振海 . 精通 MATLAB7 編程與數(shù)據(jù)庫應(yīng)用 [M]. 北京 : 電子工業(yè)出版社 ,2021. [3] 李宗 . 智能家居中燈光控制系統(tǒng)的研究 [D]. 碩士論文 . 上海 :上海交通大學(xué) ,2021. [4] 王軍宇等著 . 數(shù)字信號處理技術(shù)原理與開發(fā)應(yīng)用 [M]. 北京 : 高等教育出版社 , . [5] 葉敏著 . 數(shù)字信號處理與交換網(wǎng) [M].北京 : 北京郵電大學(xué) . [6] 吳偉陵編著 .移動通信中的關(guān)鍵技術(shù) [M].北京 .北京郵電大學(xué)出版社 ,2021 [7] 韓斌杰等著 .GSM 原理及其網(wǎng)絡(luò)優(yōu)化 [M].機械工業(yè)出版社 ,2021 附錄 一:智能家居系統(tǒng)界面的程序代碼 function varargout = untitled2(varargin) % UNTITLED2 MATLAB code for % UNTITLED2, by itself, creates a new UNTITLED2 or raises the existing % singleton*. % % H = UNTITLED2 returns the handle to a new UNTITLED2 or the handle to % the existing singleton*. % % UNTITLED2(39。CALLBACK39。,hObject,eventData,handles,...) calls the local % function named CALLBACK in with the given input arguments. % % UNTITLED2(39。Property39。,39。Value39。,...) creates a new UNTITLED2 or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before untitled2_OpeningF gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to untitled2_OpeningF via varargin. % % *See GUI Options on GUIDE39。s Tools menu. Choose GUI allows only one % instance to run (singleton). % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help untitled2 % Last Modified by GUIDE 09May2021 22:06:34 % Begin initialization code DO NOT EDIT 21 gui_Singleton = 1。 gui_State = struct(39。gui_Name39。, mfilename, ... 39。gui_Singleton39。, gui_Singleton, ... 39。gui_OpeningF39。, @untitled2_OpeningF, ... 39。gui_OutputF39。, @untitled2_OutputF, ... 39。gui_LayoutF39。, [] , ... 39。gui_Callback39。, [])。 if nargin amp。amp。 ischar(varargin{1}) = str2func(varargin{1})。 end if nargout [varargout{1:nargout}] = gui_mainf(gui_State, varargin{:})。 else gui_mainf(gui_State, varargin{:})。 end % End initialization code DO NOT EDIT % Executes just before untitled2 is made visible. function untitled2_OpeningF(hObject, eventdata, handles, varargin) % This function has no output args, see OutputF. % hObject handle to fi