Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 单选按钮组_User Interface_Matlab_Radio Button - Fatal编程技术网

User interface 单选按钮组

User interface 单选按钮组,user-interface,matlab,radio-button,User Interface,Matlab,Radio Button,我有两套按钮组。 第一个按钮组有两个单选按钮,第二个按钮组有四个单选按钮。 如果在组1和组2中选择了按钮1。类似地,对于组1中的按钮2和组2中的任何一个按钮,必须在使用这些组合单击按钮时进行相应的函数调用。怎么做。对于各自的组合,将有8个单独的函数调用。如何组合按钮组。开关箱或if-else语句不起作用??请帮忙。这里有个主意 首先,创建函数的2x4单元数组 fnc_array = {fcn11, fcn12, fcn13, fcn14; fcn21, fcn22, fcn23, fcn24};

我有两套按钮组。 第一个按钮组有两个单选按钮,第二个按钮组有四个单选按钮。 如果在组1和组2中选择了按钮1。类似地,对于组1中的按钮2和组2中的任何一个按钮,必须在使用这些组合单击按钮时进行相应的函数调用。怎么做。对于各自的组合,将有8个单独的函数调用。如何组合按钮组。开关箱或if-else语句不起作用??请帮忙。

这里有个主意

首先,创建函数的2x4单元数组

fnc_array = {fcn11, fcn12, fcn13, fcn14; fcn21, fcn22, fcn23, fcn24};
然后对组中的每个单选按钮执行
切换大小写
,并返回一个索引(第一组为fcn_index1,第二组为fcn_index2),选择哪个按钮

然后可以使用以下索引从数组中调用函数:

fcn_array{fcn_index1,fcn_index2}(arguments)

Switch和if..else当然可以,但您需要嵌套它们,即无法打开一对值

switch valA
    case 1
        if isB
            out = fcn11(args{:});
        else
            out = fcn12(args{:});
        end
    case 2
        if isB
            out = fcn21(args{:});
        else
            out = fcn22(args{:});
        end
    case 3
        if isB
            out = fcn31(args{:});
        else
            out = fcn32(args{:});
        end
    case 4
        if isB
            out = fcn41(args{:});
        else
            out = fcn42(args{:});
        end
end

这不是最好的样式,但是如果它们都使用相同的参数,那么您可以根据选择的按钮(使用sprintf和单选组的“SelectedObject”字段以及诸如:
eval(sprintf('func%s%s(args)')、get(get(handles.group1,'SelectedObject')之类的标记)动态地使用eval函数构建调用,'Tag'),get(get(handles.group2,'SelectedObject'),'Tag'))

(可以结合使用
find(get(handles.group1,'children')==get(handles.group2,'SelectedObject'))为子对象编制索引)
并注意哪个是哪个)