MATLAB如何加入滑动条,并能让滑动条滑动且得到相应数值?(要求代码,画滑动条,得数值)
想要两条就行,①往已知图片加slide,图片由imread导入,滑动条范围0~1,调节每次0.01.②在命令窗口获得由滑动条滑动所得数据,将数值赋予K。...
想要两条就行,①往已知图片加slide,图片由imread导入,滑动条范围0~1,调节每次0.01.②在命令窗口获得由滑动条滑动所得数据,将数值赋予K。
展开
2个回答
展开全部
h=figure('unit','normalized','name','Slider');
hsl=uicontrol('parent',h,'unit','normalized','style','slider','position',[.01.53 . 3 .04],'min',0,'max',5);
ht1=uicontrol('parent',h,'unit','normalized','style','text','string','0 5','position',[.01 .57 .3.04],'fontsize',10);
ht2=uicontrol('parent',h,'unit','normalized','style','text','position',[.01.71 .3 .03]);
set(hsl,'callback',['a1=get(hsl,''value'');'...
'set(ht2,''string'',a1);']);
hsl=uicontrol('parent',h,'unit','normalized','style','slider','position',[.01.53 . 3 .04],'min',0,'max',5);
ht1=uicontrol('parent',h,'unit','normalized','style','text','string','0 5','position',[.01 .57 .3.04],'fontsize',10);
ht2=uicontrol('parent',h,'unit','normalized','style','text','position',[.01.71 .3 .03]);
set(hsl,'callback',['a1=get(hsl,''value'');'...
'set(ht2,''string'',a1);']);
追问
连代码都无法运行。。。。想要两条就行,①往已知图片加slide,图片由imread导入,滑动条范围0~1,调节每次0.01.②在命令窗口获得由滑动条滑动所得数据,将数值赋予K。麻烦再写一下,会适当提高奖励的
追答
回来晚了,,,根据图片大小不同,你自己调节position参数值,使它看着好看些,,K值也已经传到命令窗口了
h=figure('unit','normalized','name','Slider');
axes('parent',h,'unit','normalized');
Picture=imread('abc.jpg');%图片
imshow(Picture);
hsl=uicontrol('parent',h,'unit','normalized','style','slider','position',[.01 .53 .3 .04],'min',0,'max',1);
ht1=uicontrol('parent',h,'unit','normalized','style','text','string','0 5','position',[.01 .57 .3 .04],'fontsize',10);
ht2=uicontrol('parent',h,'unit','normalized','style','text','position',[.01 .71 .3 .03]);
set(hsl,'callback',['K=get(hsl,''value'');'...
'set(ht2,''string'',K);']);
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询