【问题标题】:Matlab IMRECT backward compatibilityMatlab IMRECT 向后兼容性
【发布时间】:2010-02-25 08:11:30
【问题描述】:

我在 MATLAB R2009b 中编写了一个使用 IMRECT 函数的 GUI 函数。我需要确保这个 GUI 也能在 MATLAB R2007b 中工作:自从这个版本以来,IMRECT 函数已经发生了广泛的变化。我有两个问题:

1 - 在新的 (R2009b) IMRECT 中,定义了一个方法 GETCOLOR,它允许获取用户使用滚动菜单选择的颜色。有没有办法为旧 (R2007b) 函数模拟这种行为?

2 - 在 MATLAB R2009b 中,我可以在使用 IMRECT 后使用 WAIT,如下所示:

h = imrect(axhandle);
wait(h);

这允许等待用户正确放置他/她的矩形并双击以确认选择。 R2007b 中的 IMRECT 有什么类似的东西可以使用吗?

【问题讨论】:

    标签: matlab compatibility


    【解决方案1】:

    很遗憾,您需要为这两个函数找到解决方法。

    这是一种方法:

    %# Create a figure and some points
    fh = figure;plot(rand(10,1),rand(10,1),'.')
    ah = gca;
    
    %# this allows the user to place the rectangle. However, the code resumes
    %# as soon as the rectangle has been drawn
    rh = imrect(ah,[]);
    
    %# Create a dialog to have the possibility to uiwait
    wh = warndlg('Please close this dialog once you are done adjusting your rectangle');
    uiwait(wh)
    
    %# Get the color of the rectangle
    rectKids = get(rh,'Children');
    rectangleColor = get(rectKids(1),'Color');
    

    您可以使用verLessThan 检查 Matlab 版本以获得正确的功能。但是,如果有用户在 2007b 和 2009b 上都使用该代码,我建议您将对话框留给所有人,以免他们在切换时感到困惑。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多