【问题标题】:How to use effectively radio buttons in a button group MATLAB GUI如何在按钮组 MATLAB GUI 中有效使用单选按钮
【发布时间】:2025-12-08 08:55:01
【问题描述】:

我在 MATLAB GUI 中有 5 个不同的过滤器作为 5 个不同的单选按钮。我把它们做成了一个按钮组,现在当我单击每个按钮时,噪声图像通过轴显示。但我想以仅显示一个过滤器(一个图像)的方式设置按钮组。所以,我跟着这个 (How to pass function to radio button in a button group created using guide in MATLAB?) 在 * 上给出。但是我们如何在轴中“设置”图像。 我附上了我的图形用户界面。enter image description here

提前致谢

【问题讨论】:

    标签: matlab image-processing user-interface


    【解决方案1】:

    您使用正常的绘图命令将图像“设置”在axes 对象中。假设变量ax 持有您要绘制的坐标区对象的句柄,您可以编写以下代码:

    axes(ax);      % Select the chosen axes as the current axes
    cla;           % Clear the axes
    imagesc(im);   % Now draw whatever you want - for example, an image.
    

    顺便说一句,在 GUIDE 中,您通常可以使用传递给所有回调的 handles 参数来获取轴句柄。例如,如果您的坐标区名为 axes1,您的 Button Group 回调可能如下所示:

    function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)
        ax = handles.axes1;  % Get handle to axes
        axes(ax);            % Select the chosen axes as the current axes
        cla;                 % Clear the axes
        imagesc(rand(50) );  % Now draw
    

    【讨论】: