| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2947 人关注过本帖
标题:matlab 在做gui时,取编辑框的字符串,然后用eval运行为什么会出错?以下是 ...
只看楼主 加入收藏
mu12345
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-10-5
收藏
 问题点数:0 回复次数:0 
matlab 在做gui时,取编辑框的字符串,然后用eval运行为什么会出错?以下是代码
clf;
set(gcf,'unit','normalized','position',[0.2 0.3 0.55 0.36]);
set(gcf,'menubar','none','numbertitle','off','name','图形演示');
axes('position',[0.05 0.15 0.55 0.7] );
uicontrol(gcf,'style','text', 'unit','normalized','position',[0.63 0.85 0.2 0.1                                                                                                                                                                                                                                                                                                                                  ],...
   'string','输入绘图命令','horizontal','center');
hedit=uicontrol(gcf,'style','edit','unit',...
    'normalized','position',[0.63 0.15 0.2 0.68],'max',2,'horizontal','left');
hpopup=uicontrol(gcf,'style','popup','units','normalized' ,...
'position',[0.85 0.8 0.15 0.15],'string','spring|summer|autumn|winter',...                                               
   'call','fun(hedit,hpopup,hlist)');
hlist=uicontrol(gcf,'style','list','units','normalized' ,'string','grid on|grid off|box on|box off','position',...
    [0.85 0.55 0.15 0.25 ],'call','fun(hedit,hpopup,hlist)');
hpust1=uicontrol(gcf,'style','push','units','normalized' ,'position',[0.85 0.35 0.15 0.15],'string',...
    '绘图','call','fun(hedit,hpopup,hlist)');
uicontrol(gcf,'style','push','units','normalized' ,'position',[0.85 0.15 0.15 0.15],'string','关闭','call','close all');

function fun(a,b,c)
m=get(a,'string');
isstr(m)
n1=get(b,'value');
n2=get(c,'value');
if ~isempty(m)
   eval(m);%这里总报错
    k={'spring','summer','autumn','winter'};
    j={'grid on','grid off','box on','box off'};
    colormap(eval(k{n1}));
    eval(j{n2});
end
搜索更多相关主题的帖子: position matlab 字符串 style 
2016-10-05 16:15
快速回复:matlab 在做gui时,取编辑框的字符串,然后用eval运行为什么会出错?以 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033157 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved