24小时热门版块排行榜    

查看: 922  |  回复: 0

baobiao007

木虫 (职业作家)

中国特色

[交流] 一个matlab GUI 例子

CODE:
function mysinplegui

    f = figure('Color','b','MenuBar','none','Name','例子GUI','NumberTitle','off',...
               'Pointer','fleur','Resize','off','Position',[400 400 600 600]);
    movegui(f,'center');
   
    ax1 = axes('Parent',f,'Position',[.05 .6 .4 .35],'ButtonDownFcn',{@changecolor});
    ax2 = axes('Parent',f,'Position',[.55 .6 .4 .35],'ButtonDownFcn',{@copyline});
    ax3 = axes('Parent',f,'Position',[.05 .05 .4 .35],'ButtonDownFcn',{@changestyle});
    bt = uicontrol(f,'Style','PushButton','Position',[350 30 200 200],'BackgroundColor','g',...
                    'String','点我关闭','FontSize',20,'Callback',@shutdown);
   
   
   
    h1 = line(0:10,0:10,'Parent',ax1,'Color','r','LineWidth',2);
    imdata = imagesc(rand(10),'Parent',ax3);
   
    function changecolor(hobj,eventdata)
        set(h1,'Color',[rand,rand,rand]);
    end
    function copyline(hobj,eventdata)
        tp = get(hobj,'Children');
        if tp
            delete(tp)
        else
            copyobj(h1,ax2);
        end
    end
    function changestyle(hobj,eventdata)
    end
    function shutdown(hobj,eventdata)
        close(f)
    end
end

响应鼠标点击回调函数,改变图形颜色 ,复制图形对象,运行看效果
回复此楼

» 猜你喜欢

我同意叔本华的观点,人们投身艺术和科学领域的强烈愿望之一就是逃离痛苦、残酷和枯燥无味的现实生活,逃离自己飘忽不定的七情六欲的桎梏。--爱因斯坦
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

找到一些相关的精华帖子,希望有用哦~

科研从小木虫开始,人人为我,我为人人
相关版块跳转 我要订阅楼主 baobiao007 的主题更新
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见