• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

MATLAB GUI设计(3)

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

一、gca、gcf、gco

1、三者的功能定义:

gcf 返回当前Figure 对象的句柄值
gca 返回当前axes 对象的句柄值
gco 返回当前鼠标单击的句柄值,该对象可以是除root 对象外的任意图形对象,并且Matlab 会把当前图形对象的句柄值存放在Figure 的CurrentObject属性中。  

2.matlab下的图形对象

clear all
x=-pi:pi/20:pi; % create some data
y=sin(x);
z=cos(x);
plot(x,y, \'r\' ,x,z, \'g\' ); % plot two lines in red and green
Hl_lines=get(gca, \'Children\' ); % get the line handles
for k=1:size(Hl_lines) % find the green line
    if get(Hl_lines(k), \'Color\' )==[0 1 0]
       Hl_green=Hl_lines(k)
    end
end

二、对象基础操作及概念

clear all
plot([0:10])
title(\'示例\')

allchild(gcf)%获取当前图的子对象 

 

get(gcf)

 

get(gca)

set(gca(1),\'Position\',[0.1300 0.1100 0.5 0.5],\'color\',[0 1 0])

三、

clear all
%创建axes坐标图
h = axes();
%定义图形位置和大小,[left bottom width height]
set(h,\'Position\',[0.1 0.1 0.8 0.8]);
%画图
x=0:0.01:12;
y=sin(x);
plot(h,sin(x));
%Sets the location of the tick marks along the axis
set(h,\'XTickLabel\',[0;2;4;6;8;10;12;14]);
%显示方格
set(h,\'XGrid\',\'on\',\'YGrid\',\'on\');
%设置颜色、字体等属性
set(h,\'XColor\',[0 0 0.7],...
       \'YColor\',[0.7 0 0.7],...
       \'Color\',[.9 .5 .9],...
       \'GridLineStyle\',\'--\',...
       \'FontName\',\'times\',...
       \'FontAngle\',\'italic\',...
       \'FontSize\',14);
%定义X坐标和Y坐标的标签名
set(get(h,\'XLabel\'),\'String\',\'Values of X\',...
                    \'FontName\',\'times\',...
                    \'FontAngle\',\'italic\',...
                    \'FontSize\',14);
set(get(h,\'YLabel\'),\'String\',\'Values of Y\',...
                    \'FontName\',\'times\',...
                    \'FontAngle\',\'italic\',...
                    \'FontSize\',14)
%定义图形标题名                
set(get(h,\'Title\'),\'String\',\'y=sin(x)\',...
                    \'FontName\',\'times\',...
                    \'Color\',[0 0 0.7],...
                    \'FontSize\',14);

 

  

 

  

  

  

  

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap