打印

matlab 指定坐标轴范围

[复制链接]
128|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
cooldog123pp|  楼主 | 2024-5-25 10:52 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
指定坐标轴范围

h0=figure('toolbar','none',...
    'position',[198 56 408 468],...
    'name','实例49');
h1=axes('parent',h0,...
    'position',[0.15 0.45 0.7 0.5],...
    'visible','on');
x=0:0.1:2*pi;
y=sin(x);
plot(x,y);
xlabel('X');
ylabel('Y');
title('坐标轴范围的改变');
h=get(gca,'xlim');
k=get(gca,'ylim');
e1=uicontrol('parent',h0,...
    'style','edit',...
    'string',eval(num2str(h(1))),...
    'horizontalalignment','right',...
    'position',[80 120 100 20]);
t1=uicontrol('parent',h0,...
    'style','text',...
    'string','X轴最小值',...
    'position',[100 145 80 20]);
e2=uicontrol('parent',h0,...
    'style','edit',...
    'string',eval(num2str(h(2))),...
    'horizontalalignment','right',...
    'position',[80 60 100 20]);
t2=uicontrol('parent',h0,...
    'style','text',...
    'string','X轴最大值',...
    'position',[100 85 80 20]);
e3=uicontrol('parent',h0,...
    'style','edit',...
    'string',eval(num2str(k(1))),...
    'horizontalalignment','right',...
    'position',[250 120 100 20]);
t3=uicontrol('parent',h0,...
    'style','text',...
    'string','Y轴最小值',...
    'position',[270 145 80 20]);
e4=uicontrol('parent',h0,...
    'style','edit',...
    'string',eval(num2str(k(2))),...
    'horizontalalignment','right',...
    'position',[250 60 100 20]);
t4=uicontrol('parent',h0,...
    'style','text',...
    'string','X轴最小值',...
    'position',[270 85 80 20]);
p1=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','设置',...
    'position',[105 10 50 30],...
    'callback',[...
        'a=str2num(get(e1,''string''));,',...
        'b=str2num(get(e2,''string''));,',...
        'c=str2num(get(e3,''string''));,',...
        'd=str2num(get(e4,''string''));,',...
        'axis([a b c d]),',...
        'drawnow']);
p2=uicontrol('parent',h0,...
    'style','pushbutton',...
    'string','关闭',...
    'position',[275 10 50 30],...
    'callback','close');


使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1654

主题

5986

帖子

29

粉丝