声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1272|回复: 7

[GUI界面] 关于显示图形的问题

[复制链接]
发表于 2007-4-7 17:54 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
我已经将Axes属性中的Nextplot属性设为replace,
但是为什么后来画出的图形还是和前面的图形一起显示出来了呢?
我要单独显示啊!
回复
分享到:

使用道具 举报

发表于 2007-4-7 19:42 | 显示全部楼层
原帖由 jennychung 于 2007-4-7 17:54 发表
我已经将Axes属性中的Nextplot属性设为replace,
但是为什么后来画出的图形还是和前面的图形一起显示出来了呢?
我要单独显示啊!



该属性并非这个意思。单独显示,可以使用2个figure,或者subplot
 楼主| 发表于 2007-4-7 21:09 | 显示全部楼层
我想做的是:
按下plot按扭在axes里显示图像
再按一下plot,还是在axes里显示新画出的图象
发表于 2007-4-7 21:11 | 显示全部楼层
原帖由 jennychung 于 2007-4-7 21:09 发表
我想做的是:
按下plot按扭在axes里显示图像
再按一下plot,还是在axes里显示新画出的图象



使用同一个figure的句柄就可以了

如果还是不行,给出你的代码吧
 楼主| 发表于 2007-4-7 21:18 | 显示全部楼层
代码很长啊
简单一下
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
hk=findobj('tag','edit1');K=str2num(get(hk,'string'));
ht=findobj('tag','edit2');T=str2num(get(ht,'string'));
hlei=findobj('tag','popupmenu1');lei=get(hlei,'value');
axes(handles.axes1);
switch lei
    case 1
        a=[0,1;0,-1/T];b=[0,K/T]';ts=0.05;[phi,del]=c2d(a,b,ts);
        xnl=[0 0]';xnlold=xnl;xlin=[0 0]';xlinold=xlin;t=0;u=4;tend=20;ks=2;gs=2;
        while t<tend
            t=[t t(length(t))+ts];enl=gs*(u-xnlold(1));elin=gs*(u-xlinold(1));
            if enl>=ks,enlsat=ks;
            elseif enl<=-ks,enlsat=-ks;
            else enlsat=enl;
            end
            xnlold=phi*xnlold+del*enlsat;xnl=[xnl xnlold];
            xlinold=phi*xlinold+del*elin;xlin=[xlin xlinold];
        end
        plot(xlin(1,:),xlin(2,:),'b'),grid on;hold on;plot(xnl(1,:),xnl(2,:),'r');
    case 2
        .....        
        plot(xlin(1,:),xlin(2,:),'b'),grid on;hold on;plot(xnl(1,:),xnl(2,:),'r');
    case 3
        ......        
        plot(xlin(1,:),xlin(2,:),'b'),grid on;hold on;plot(xnl(1,:),xnl(2,:),'r');
    case 4
       ......      
       plot(xlin(1,:),xlin(2,:),'b'),grid on;hold on;plot(xnl(1,:),xnl(2,:),'r');
end

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
hk=findobj('tag','edit1');K=str2num(get(hk,'string'));;
ht=findobj('tag','edit2');T=str2num(get(ht,'string'));;
hlei=findobj('tag','popupmenu1');lei=get(hlei,'value');
axes(handles.axes1);
switch lei
    case 1
        a=[0,1;0,-1/T];b=[0,K/T]';ts=0.05;[phi,del]=c2d(a,b,ts);
        xnl=[0 0]';xnlold=xnl;xlin=[0 0]';xlinold=xlin;t=0;u=4;tend=20;ks=2;gs=2;
        while t<tend
            t=[t t(length(t))+ts];enl=gs*(u-xnlold(1));elin=gs*(u-xlinold(1));
            if enl>=ks,enlsat=ks;
            elseif enl<=-ks,enlsat=-ks;
            else enlsat=enl;
            end
            xnlold=phi*xnlold+del*enlsat;xnl=[xnl xnlold];
            xlinold=phi*xlinold+del*elin;xlin=[xlin xlinold];
        end
        plot(t,xlin(1,:),'b'),grid on;hold on;plot(t,xnl(1,:),'r');
    case 2
        ....
        plot(t,xlin(1,:),'b'),grid on;hold on;plot(t,xnl(1,:),'r');        
    case 3
        ....
        plot(t,xlin(1,:),'b'),grid on;hold on;plot(t,xnl(1,:),'r');
    case 4
       ....
       plot(t,xlin(1,:),'b'),grid on;hold on;plot(t,xnl(1,:),'r');
end
发表于 2007-4-7 21:20 | 显示全部楼层
用hold on命令
或者plot(x,y,x,z)
发表于 2007-4-7 21:24 | 显示全部楼层
原帖由 jennychung 于 2007-4-7 21:18 发表
代码很长啊
简单一下
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLA ...


按照你的代码,应该没有问题波。你说说如何运行的?

ps:可能是你hold on后没有hold off,即:
  1. plot(xlin(1,:),xlin(2,:),'b'),grid on;hold on;plot(xnl(1,:),xnl(2,:),'r');hold off;
复制代码

试试吧
 楼主| 发表于 2007-4-7 21:27 | 显示全部楼层
果然有用 啊
谢谢拉
一直看到你,果然是高手啊
还有 个问题的
http://forum.vibunion.com/forum/ ... &extra=page%3D1
帮忙看看啊

[ 本帖最后由 jennychung 于 2007-4-7 21:28 编辑 ]
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-6-1 23:49 , Processed in 0.060831 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表