1-》GUI程序设计-底层代码
%打开文件 uigetfile uigetfile(\'*.m\') doc uigetfile [a,b,c]=uigetfile(\'*.m\') a=文件的名字 b=文件的路径 c=点击的确定还是取消 %保存文件 uiputfile [a,b,c]=uiputfile(\'*.m\') 后边需要其他函数辅助使用
%颜色设置 uisetcolor c=uisetcolor([r b g]) figure b=uicontrol(\'Parent\',gcf,\'String\',\'颜色设置\',\'Steyle\',\'pushbutton\',\'Callback\',... \'c=uisetcolor;set(b,\'\'BackgroundColor\'\',c);.\'); %字体设置 uisetfont S=uisetfont figure b=uicontrol(\'Parent\',gcf,\'String\',\'颜色设置\',\'Steyle\',\'pushbutton\',\'Callback\',... \'uisetfont(b);.,\'Position\',[0.2 0.2 0.8 0.8],\'Units\',\'Normalized\');
%进度条 %watbar h= waitbar(0,\'实例\') %获得进度条的子对象 get(get(h,\'Children\')) ha=get(h,\'Children\')
%普通对话框 dialog h = dialog(\'name\',\'关于。。。\',\'Position\',[200 200 200 70]); uicontrol(\'parent\',h,\'style\',\'pushbutton\',\'Position\',[80 0 50 20],... \'string\',\'确定\',\'Callback\',\'delete(gcbf)\'); %错误对话框 errordlg %警告对话框 warndlg
%输入对话框 name=inputdlg(\'请输入姓名\',\'实例\') ret=inputdlg({\'请输入姓名\'.\'请输入性别\'},\'实例\') info=inputdlg(\'请留言\',\'留言\',5) re=inputdlg({\'请输入姓名\'.\'请输入性别\'},\'实例\',1,{\'lssada\',\'男\'},\'on\') %输入目录对话框 uigetdir uigetdir(\'C:\\'.\'浏览\') %列表选择对话框 listdlg [sel,ok]=listdlg(\'\'\' \'ListString\',{\'A\',\'B\',\'C\',\'D\'}... \'OKString\',\'确定\'... \'CancelString\',\'取消\'... \'Name\',\'选择\'... \'SlectionMode\',\'single\');
2-》GUIDE设计-图形
3-》类的使用
classdef Cat < handle %UNTITLED ´Ë´¦ÏÔʾÓйشËÀàµÄÕªÒª % ´Ë´¦ÏÔʾÏêϸ˵Ã÷ %Òþ²Ø·ÃÎÊȨÏÞ properties(Access=private)%ÏÞÖÆÊôÐÔ % properties age end properties(Access=public) name type end %¶¨Òå³ÉÔ±·½·¨ methods(Access=private) function speak(obj) disp(\'ÄãºÃ\'); end end methods %¹¹Ôì·½·¨£¬³õʼ»¯ function obj = Cat(name,age,type) %UNTITLED ¹¹Ôì´ËÀàµÄʵÀý % ´Ë´¦ÏÔʾÏêϸ˵Ã÷ obj.name=name; obj.age=age; obj.type=type; end function meow(obj) %METHOD1 ´Ë´¦ÏÔʾÓйش˷½·¨µÄÕªÒª % ´Ë´¦ÏÔʾÏêϸ˵Ã÷ disp([\'ÎÒ½Ð\' obj.name \'ß÷ß÷£¡~\']); obj.speak(); end function change_name(obj,name) obj.name=name; end end end