matlab gui(三)对话框(文件打开/保存对话框,进度条)

%% 文件打开/保存
%uigetfile
uigetfile%默认获得(不是打开)文件对话框
doc uigetfile
%规定打开文件类型
uigetfile('*.m');
%输出参数的意义,可看上边的doc文件
[filename,path,sureORcancel]=uigetfile;
if(sureORcancel==1)
    load(fullfile(filename,path));
end
uigetfile('*.m','实例','default.m');
%输入/保存文件
[a b c]=inputfile('*.m');

%% 颜色/字体设置对话框
uisetcolor
doc uisetcolor
c=uisetcolor([1 0 0])
h=plot(0:10);
c=uisetcolor(h);%将句柄加入,可以设置其代表的图形的颜色
b=uicontrol('Parent',gcf,'String','颜色值','Style','pushbutton', ...
    'Callback','c=uisetcolor;set(b,''BackgroundColor'',c);');
%字体对话框
uisetfont(b);
%% 进度条
h=waitbar(0,'MySample');
get(h)%进度条由,坐标,{line,patch(面)},组成
get(get(h,'Children'));
ha=get(h,'Children');
%获得坐标轴子对象的子对象的内容
get(ha,'Children')
get(ans(1))
get(ans(2))

%获得个对象的内容就可改变其属性
hrand=waitbar(0.3,'颜色')
ha1=get(hrand,'Children');
hac=get(ha1,'Children');%ha1子对像的句柄列表
hapa=findall(hac,'Type','patch');
set(hapa,'Facecolor','k');
%% 普通对话框
dialog
h=dialog('name','aboutme', ...
    'Position',[200 200 200 70]);
uicontrol('Style','pushbutton', ...
    'Parent',h, ...
    'Callback','plot(cos([0:0.1:6]))', ...
    'String','确定', ...
    'Units','Normalized', ...
    'Position',[0.1 0.1 0.2 0.2]);
%错误/警告对话框
errordlg
warndlg
%% 输入对话框
name=inputdlg('input your name','MySample');
name=inputdlg({'input your name','age'},'MySample');
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值