标签:plot slider 根据 tle bubuko unit nta ext 分享图片
一、查询图形对象属性
1、感觉一个 get 就可以搞定一切。。。额,再加一个 set 。。。
2、修改对象属性值:
3、操作函数
function []=example()
s.fh=figure(‘units‘,‘normalized‘,...
‘position‘,[0.1,0.1,0.3,0.3],...
‘menubar‘,‘none‘,...
‘name‘,‘example‘,...
‘numbertitle‘,‘off‘,...
‘resize‘,‘on‘);
s.text=uicontrol(‘style‘,‘text‘,...
‘unit‘,‘normalized‘,...
‘position‘,[0.1,0.85,0.4,0.05],...
‘string‘,‘change color‘);
s.pop=uicontrol(‘style‘,‘popupmenu‘,...
‘unit‘,‘normalized‘,...
‘position‘,[0.6,0.8,0.3,0.1],...
‘string‘,{‘red‘;‘green‘;‘blue‘;‘yellow‘;‘black‘;‘cyan‘;‘magenta‘});
s.axes=axes(‘unit‘,‘normalized‘,...
‘position‘,[0.1,0.1,0.8,0.7]);
x=0:pi/50:8*pi;
y=sin(x);
axes(s.axes);
s.hplot=plot(x,y,‘color‘,[1 0 0]);
set(s.pop,‘callback‘,{@mycallback,s});
function mycallback(obj,~,s)
val=get(obj,‘value‘);
switch val
case 1
set(s.hplot,‘color‘,[1 0 0]);
case 2
set(s.hplot,‘color‘,[0 1 0]);
case 3
set(s.hplot,‘color‘,[0 0 1]);
case 4
set(s.hplot,‘color‘,[1 1 0]);
case 5
set(s.hplot,‘color‘,[0 0 0]);
case 6
set(s.hplot,‘color‘,[0 1 1]);
case 7
set(s.hplot,‘color‘,[1 0 1]);
end
ps: (1)s:结构体(句柄结构)
代码简洁;便于句柄在回调函数之间传递
(2)callback:将其属性设置为函数句柄
对图像进行控制
(3)propedit:
二、用户界面控件
1、为按钮加背景图片
[a,map]=imread(‘mute.jpg‘);
[r,c,d]=size()a;
x=ceil(r/30);
y=ceil(c/30);
g=a(1:x:end,1:y:end,:);
set(hpush,‘cdata‘,g);
2、value 的值表示控件是否选中
checkbox,listbox,popupmenu,pushbutton,radiobutton,slider,togglebutton,buttongroup,
标签:plot slider 根据 tle bubuko unit nta ext 分享图片
原文地址:https://www.cnblogs.com/ileanj1998/p/9157521.html