Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.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

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
将响应从matlab中的GUI保存为struct_Matlab_User Interface_Response - Fatal编程技术网

将响应从matlab中的GUI保存为struct

将响应从matlab中的GUI保存为struct,matlab,user-interface,response,Matlab,User Interface,Response,我应该将输入的字符串或选择的值分配给回调函数中的结构。我有下面这样的东西,但我不能把它嵌入到函数中。在命令窗口中,matlab返回一些数值而不是响应 %subject.name=NameAns %subject.gender=GenderAns function b d = dialog('Position',[300 300 300 300],'Name','My Dialog'); NameAns = uicontrol('Parent', d,...

我应该将输入的字符串或选择的值分配给回调函数中的结构。我有下面这样的东西,但我不能把它嵌入到函数中。在命令窗口中,matlab返回一些数值而不是响应

%subject.name=NameAns %subject.gender=GenderAns

  function b

    d = dialog('Position',[300 300 300 300],'Name','My Dialog');


    NameAns = uicontrol('Parent', d,...
            'Style', 'edit',...
            'String','Type Your Name',...
            'position', [70 260 100 20] )



    GenderAns = uicontrol('Parent', d,...
                    'Style', 'popup', 'String', {'female','male', 'other'},...
                    'Position', [70 230 90 20 ])

    uicontrol('Parent', d, 'Style', 'pushbutton',...
        'String', 'OK',...
        'Position', [90, 90, 110, 30],...
        'FontSize',18,'Callback',@OKCallBack);


    function ConfCallBack(source,eventdata)
            disp(get(source,'Value'));

     subject.name = NameAns
    subject.gender = GenderAns

             uiwait (d)
    end

        function OKCallBack(source,eventdata)
            close(d)
        end

    end

您必须从
NameAns
GenderAns
获取
String
值。现在您正在存储
uicontrol
对象…请编辑您的问题并修复代码的缩进。