声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2039|回复: 4

[编程技巧] 小问题eval的使用

[复制链接]
发表于 2006-12-1 21:12 | 显示全部楼层 |阅读模式

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

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

x
这个程序是照书上抄的. 但是我不明白,为什么eval()函数中,那个变量是这么写的eval(ct')为什么变量上面会有那么一撇呢
function exm104_3()
global hedit hpop hlist
clf reset
set(gcf,'unit','normalized','position',[0.1,0.4,0.85,0.35]);
set(gcf,'defaultuicontrolunits','normalized');
set(gcf,'defaultuicontrolfontsize',11);
set(gcf,'defaultuicontrolfontname','隶书');
set(gcf,'defaultuicontrolhorizontal','left');
set(gcf,'menubar','none')
str='通过多行指令绘图的交互界面';
set(gcf,'name',str,'numbertitle','off');
h_axes=axes('position',[0.05,0.15,0.45,0.7],'visible','off')
uicontrol(gcf,'Style','text',...
           'position',[0.52 0.87 0.26 0.1],...
           'String','绘图指令输入框')
hedit=uicontrol(gcf,'Style','edit',...
           'position',[0.52 0.05 0.26 0.8],...
            'Max',2)
hpop=uicontrol(gcf,'Style','popup',...
           'position',[0.8 0.73 0.18 0.12],...
           'String','spring|summer|autumn|winter');
hlist=uicontrol(gcf,'Style','list',...
           'position',[0.8 0.23 0.18 0.37],...
           'String','Grid on|Box on|Hidden off|Axis off',...
            'Max',2)
hpush=uicontrol(gcf,'Style','push',...
           'position',[0.8 0.05 0.18 0.15],...
           'String','Apply')
set(hedit,'callback','calledit1');
set(hpop,'callback','calledit1');
set(hpush,'callback','calledit1');   

function calledit1
global hedit hpop hlist
ct=get(hedit,'string');
vpop=get(hpop,'value');
vlist=get(hlist,'value');
if ~isempty(ct)
    eval(ct')
    popstr={'spring','summer','autumn','winter'};
    liststr={'grid on','box on','hidden off','axis off'};
    invstr={'grid off','box off','hidden on','axis on'};
    colormap(eval(popstr{vpop}))
    w=zeros(1,4);w(vlist)=1;
    for k=1:4
        if w(k); eval(liststr{k});else eval(invstr{k});end
    end
end

程序可以运行成功。我就是不明白那个eval函数括号里的写法。
谢谢各位了。
回复
分享到:

使用道具 举报

 楼主| 发表于 2006-12-1 21:16 | 显示全部楼层
说简练一点就是不知道eval(ct')这个写法代表什么意思?
发表于 2006-12-1 22:32 | 显示全部楼层
你把这点去除看看还能运行吗?
 楼主| 发表于 2006-12-3 19:04 | 显示全部楼层
当然不行啊.
eval是不是列取值
发表于 2012-7-19 08:19 | 显示全部楼层
将字符串作为数据输出的。
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-9-21 03:34 , Processed in 0.067549 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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