入力として 1 つの変数を受け取り、別の変数を生成するいくつかの操作を実行する GUI をプログラムしようとしています。GUI には、GUI を閉じるプッシュボタンが 1 つあります。
私は GUIDE を使用していません (そして使用したくありません)。
以下に、入力変数に 1 を追加するだけの GUI の最小限の作業例を示します。「完了」プッシュ ボタンで GUI を閉じますが、変数をワークスペースにエクスポートする方法が見つかりません。
% Is this the correct way to initialize the function for what I am trying to do?
function outputVariable = exampleGUI(inputVariable) 
    % Initialize main figure
    hdl.mainfig = figure();
    % Add Button
    hdl.addPushButton = uicontrol(hdl.mainfig, 'Units', 'normalized',
                                  'Position', [0.05 0.6 0.3 0.25], 'String',
                                  'Add One', 'Callback', @addOne);
    % Done Button
    hdl.donePushButton = uicontrol(hdl.mainfig, 'Units', 'normalized',
                                   'Position', [0.65 0.6 0.3 0.25], 'String',
                                   'Done', 'Callback', @done);
    % Static text
    hdl.sliceNoText = uicontrol(hdl.mainfig, 'Style', 'text',
                                'Fontsize', 16, 'Units', 'normalized', 
                                'Position', [0.35 0.2 0.3 0.25]);
    function addOne(~, ~, ~)
        inputVariable = inputVariable + 1; % add one to the current inputVariable
        set(hdl.sliceNoText, 'String', num2str(inputVariable)); % change static text
        newVariable = inputVariable; % new variable to be exported
    end
    function done(~, ~, ~)   
        delete(hdl.mainfig); % close GUI
    end
end
私は次のようなことをしたいと思います:
ワークスペースで:
outputVariable = exampleGUI(inputVariable)
入力変数に一定回数追加した後、「完了」ボタンを押して GUI を閉じ、ワークスペースに inputVariable と outputVariable の両方が含まれるようにします。
どうもありがとう。
フネリー