2

这是一个非常简单的问题,但是在阅读文档后,我无法将位置属性分配给一组轴控件。我实际上想为一组 11 个轴控件设置 2 个属性,特别是位置和父属性。这是我正在使用的代码:

set(h.AXES_ALL(1:11),'parent',h.fig,{'position'},{ ...
    [30/win_pos(3) 460/win_pos(4) 240/win_pos(3) 190/win_pos(4)]  ...
    [300/win_pos(3) 460/win_pos(4) 240/win_pos(3) 190/win_pos(4)] ...
    [570/win_pos(3) 460/win_pos(4) 240/win_pos(3) 190/win_pos(4)] ...
    [840/win_pos(3) 460/win_pos(4) 240/win_pos(3) 190/win_pos(4)] ...
    [1110/win_pos(3) 460/win_pos(4) 240/win_pos(3) 190/win_pos(4)]...
    [30/win_pos(3) 240/win_pos(4) 240/win_pos(3) 190/win_pos(4)]  ...
    [300/win_pos(3) 240/win_pos(4) 240/win_pos(3) 190/win_pos(4)] ...
    [570/win_pos(3) 240/win_pos(4) 240/win_pos(3) 190/win_pos(4)] ...
    [840/win_pos(3) 240/win_pos(4) 240/win_pos(3) 190/win_pos(4)] ...
    [1110/win_pos(3) 240/win_pos(4) 240/win_pos(3) 190/win_pos(4)]...
    [570/win_pos(3) 20/win_pos(4) 240/win_pos(3) 190/win_pos(4)]    })

wherewin_pos是对应窗口位置的向量。MATLAB给出的错误是:

参数单元/值单元对中的大小不匹配

那么,是否可以将这两个属性更改为一大组控件?

4

1 回答 1

3

要将单个属性的不同值分配给多个对象,值的单元格数组需要是column,而不是 row (请参阅doc)。所以:.'在你的最后一个之后添加}

set(h.AXES_ALL(1:11),'parent',h.fig,{'position'},{[30/win_pos(3) 460/win_pos(4) 240/win_pos(3) 190/win_pos(4)]  ...
                                       [300/win_pos(3) 460/win_pos(4) 240/win_pos(3) 190/win_pos(4)] ...
                                       [570/win_pos(3) 460/win_pos(4) 240/win_pos(3) 190/win_pos(4)] ...
                                       [840/win_pos(3) 460/win_pos(4) 240/win_pos(3) 190/win_pos(4)] ...
                                       [1110/win_pos(3) 460/win_pos(4) 240/win_pos(3) 190/win_pos(4)]...
                                       [30/win_pos(3) 240/win_pos(4) 240/win_pos(3) 190/win_pos(4)]  ...
                                       [300/win_pos(3) 240/win_pos(4) 240/win_pos(3) 190/win_pos(4)] ...
                                       [570/win_pos(3) 240/win_pos(4) 240/win_pos(3) 190/win_pos(4)] ...
                                       [840/win_pos(3) 240/win_pos(4) 240/win_pos(3) 190/win_pos(4)] ...
                                       [1110/win_pos(3) 240/win_pos(4) 240/win_pos(3) 190/win_pos(4)]...
                                       [570/win_pos(3) 20/win_pos(4) 240/win_pos(3) 190/win_pos(4)]    }.')
于 2013-11-08T11:39:10.397 回答