MATLAB编写回调函数(部分 更新)
2015-01-11 16:33
260 查看
t=0:0.001:4*pi;
figure('menubar','none');
x=plot(t,sin(t));
grid on;
set(gca,'xlim',[0 2*pi]);
h1=uimenu('label','颜色设置');
c1=set(x,'Color','red');
c2=set(x,'Color','green');
c2=set(x,'Color','blue');
uimenu(h1,'label','红色','accelerator','R','callback',c1);
uimenu(h1,'label','绿色','accelerator','G','callback',c2);
uimenu(h1,'label','蓝色','accelerator','B','callback',c3);
x=rand(10,4);
figure;
h=uitable('data',x);
set(h,'units','normalized','position',[0.1 0.5 0.8 0.8]);
% msgbox('warning','title','warn');
% warndlg('warning');
a=inputdlg({'user name:'...
,'passward:'},...
'log in');
c=questdlg('Are you sure to close the dialog ?');
switch c,
case 'Yes'
disp('you choose yes !');
case 'No'
disp('you choose no !');
case 'Cancel'
disp('you choose cancle !');
end
a=get(handles.edit1,'String');
if isempty(a)
set(handles.edit1,'String','0');
end
guidata(hObject,handles);
a=get(handles.edit2,'String');
if isempty(a)
set(handles.edit2,'String','0');
end
guidata(hObject,handles);
a=get(handles.edit1,'String');
b=get(handles.edit2,'String');
c=str2num(a)*str2num(b);
set(handles.text3,'String',num2str(c));
guidata(hObject,handles);
a=get(handles.edit2,'String');
if isempty(a)
set(handles.edit2,'String','0');
end
guidata(hObject,handles);
h=gca;
cla(h);
set(handles.edit1,'String','10');
set(handles.edit2,'String','0');
set(handles.edit3,'String','1');
x=linspace(-5,5,50);
y=x;
for w=2:0.5:6
[X Y]=meshgrid(x,y);
Z=1/sqrt(2*pi)*w.*exp(-(X.^2+Y.^2))./2*w*w;
mesh(X,Y,Z);
axis equal;
pause(0.5);
end
a=str2num(get(handles.edit1,'String'));
b=str2num(get(handles.edit2,'String'));
c=str2num(get(handles.edit3,'String'));
x=linspace(-a,a,50);
y=linspace(-b,b,50);
w=c;
[X Y]=meshgrid(x,y);
Z=1/sqrt(2*pi)*w.*exp(-(X.^2+Y.^2))./2*w*w;
mesh(X,Y,Z);
axis equal;
h=gca;
cla(h);
set(handles.edit1,'String','0');
set(handles.edit2,'String','0');
set(handles.edit3,'String','1');
val=get(hObject,'Value');
str=get(hObject,'String');
switch str{val}
case 'peaks'
handles.current_data=handles.peaks;
case 'sphere'
handles.current_data=handles.sphere;
case 'sinc'
handles.current_data=handles.sinc;
end
guidata(hObject,handles);
+++++++++++++++++++++++++++++++++++++
h=figure;%创建一个窗口
% get(h) %获得h的所有属性
set(h,'units','normalized','menu','none',...
'Position',[0.1 0.1 0.5 0.5]); %设置h的有关属性
ha=axes;
set(ha,'parent',h,'units','normalized',...
'position',[0.1 0.1 0.8 0.8]);%注意此处为设置ha的属性
%指定其父对象为h,h不加引号
x=linspace(-8,8,1000);
y=sinc(x);
h1=line('parent',ha,'xdata',x,'ydata',y,...
'color','r');
str='bgrcmykw';
for i=1:length(str)
set(h1,'color',str(i));
pause(2);
end
h=figure('units','normalized','menu',...
'none','position',[0.1 0.1 0.5 0.5]);
ha=axes('parent',h,'units','normalized'...
,'position',[0.1 0.1 0.8 0.8]);
x=linspace(-5,5,100);
y=sinc(x);
h1=line('parent',ha,'xdata',x,...
'ydata',y,'color','r','linewidth',2);
str='dhopsx';
for i=1:length(str)
set(h1,'marker',str(i));
pause(2);
end
figure('menubar','none');
x=plot(t,sin(t));
grid on;
set(gca,'xlim',[0 2*pi]);
h1=uimenu('label','颜色设置');
c1=set(x,'Color','red');
c2=set(x,'Color','green');
c2=set(x,'Color','blue');
uimenu(h1,'label','红色','accelerator','R','callback',c1);
uimenu(h1,'label','绿色','accelerator','G','callback',c2);
uimenu(h1,'label','蓝色','accelerator','B','callback',c3);
x=rand(10,4);
figure;
h=uitable('data',x);
set(h,'units','normalized','position',[0.1 0.5 0.8 0.8]);
% msgbox('warning','title','warn');
% warndlg('warning');
a=inputdlg({'user name:'...
,'passward:'},...
'log in');
c=questdlg('Are you sure to close the dialog ?');
switch c,
case 'Yes'
disp('you choose yes !');
case 'No'
disp('you choose no !');
case 'Cancel'
disp('you choose cancle !');
end
a=get(handles.edit1,'String');
if isempty(a)
set(handles.edit1,'String','0');
end
guidata(hObject,handles);
a=get(handles.edit2,'String');
if isempty(a)
set(handles.edit2,'String','0');
end
guidata(hObject,handles);
a=get(handles.edit1,'String');
b=get(handles.edit2,'String');
c=str2num(a)*str2num(b);
set(handles.text3,'String',num2str(c));
guidata(hObject,handles);
a=get(handles.edit2,'String');
if isempty(a)
set(handles.edit2,'String','0');
end
guidata(hObject,handles);
h=gca;
cla(h);
set(handles.edit1,'String','10');
set(handles.edit2,'String','0');
set(handles.edit3,'String','1');
x=linspace(-5,5,50);
y=x;
for w=2:0.5:6
[X Y]=meshgrid(x,y);
Z=1/sqrt(2*pi)*w.*exp(-(X.^2+Y.^2))./2*w*w;
mesh(X,Y,Z);
axis equal;
pause(0.5);
end
a=str2num(get(handles.edit1,'String'));
b=str2num(get(handles.edit2,'String'));
c=str2num(get(handles.edit3,'String'));
x=linspace(-a,a,50);
y=linspace(-b,b,50);
w=c;
[X Y]=meshgrid(x,y);
Z=1/sqrt(2*pi)*w.*exp(-(X.^2+Y.^2))./2*w*w;
mesh(X,Y,Z);
axis equal;
h=gca;
cla(h);
set(handles.edit1,'String','0');
set(handles.edit2,'String','0');
set(handles.edit3,'String','1');
val=get(hObject,'Value');
str=get(hObject,'String');
switch str{val}
case 'peaks'
handles.current_data=handles.peaks;
case 'sphere'
handles.current_data=handles.sphere;
case 'sinc'
handles.current_data=handles.sinc;
end
guidata(hObject,handles);
+++++++++++++++++++++++++++++++++++++
h=figure;%创建一个窗口
% get(h) %获得h的所有属性
set(h,'units','normalized','menu','none',...
'Position',[0.1 0.1 0.5 0.5]); %设置h的有关属性
ha=axes;
set(ha,'parent',h,'units','normalized',...
'position',[0.1 0.1 0.8 0.8]);%注意此处为设置ha的属性
%指定其父对象为h,h不加引号
x=linspace(-8,8,1000);
y=sinc(x);
h1=line('parent',ha,'xdata',x,'ydata',y,...
'color','r');
str='bgrcmykw';
for i=1:length(str)
set(h1,'color',str(i));
pause(2);
end
h=figure('units','normalized','menu',...
'none','position',[0.1 0.1 0.5 0.5]);
ha=axes('parent',h,'units','normalized'...
,'position',[0.1 0.1 0.8 0.8]);
x=linspace(-5,5,100);
y=sinc(x);
h1=line('parent',ha,'xdata',x,...
'ydata',y,'color','r','linewidth',2);
str='dhopsx';
for i=1:length(str)
set(h1,'marker',str(i));
pause(2);
end
相关文章推荐
- 常见代码的编写规范(四)---对象的保存与更新
- 常见代码的编写规范(四)---对象的保存与更新
- 使用 .NET 和后台智能传输服务 API 来编写自动更新应用程序
- C#编写局域网管理工具“网络管理员”1.0正式版(2007-4-30最后更新)
- 编写组件,使用JavaScript更新UpdatePanel
- IBM Lotus Domino 7 中的实用 Web 服务,第 2 部分: 编写和测试简单的 Web 服务
- 补充部分官方文档里没有的Client Library以及代码提示Schema更新(一)
- 补充部分官方文档里没有的Client Library以及代码提示Schema更新(三)
- COM入门第二部分 - 编写COM Server
- 程序安装,升级及卸载核心部分(java编写)
- 数据库架构更新Sql语句编写规范
- 创造一个完全不可能重复的整数(以更新公式说明部分)
- 掌握 Ajax:第 5 部分: 操纵 DOM使用 JavaScript 即时更新 Web 页面
- 这几天都在编写内存管理部分得代码
- crontab结合用PHP编写的shell完成自动更新数据的程序
- 编写你自己的GPS应用程序:第二部分
- 使用 .NET 和后台智能传输服务 API 来编写自动更新应用程序
- 补充部分官方文档里没有的Client Library以及代码提示Schema更新(一)
- 编写组件,使用JavaScript更新UpdatePanel
- 编写组件,使用JavaScript更新UpdatePanel (转载)