1

GUI を作成しています (GUIDE を使用していません)。ユーザーがデータを入力するための便利な方法を探しています。テーブルからのユーザー入力を保存する方法がわからないことを除いて、uitableが理想的だと思いました。celleditcallback 関数を使用したくない - 理想的には、保存ボタンなどを使用して最後にデータを一度に保存したいのですが、何かアイデアはありますか? テーブルのコード (これは独自の関数内にあります):

dat =  {0,  0,  0, true;...
        0,  0,  0, true;...   
        0,  0,  0, true;};
columnname =   {'x-pos', 'y-pos', 'dimns', 'Include?'};
NC = numel(columnname);
rowNumber = zeros(NR,NC);
columnformat = {'numeric', 'numeric', 'numeric','logical'};
columneditable =  [true true true true true];
rowname = {'Dat1','Dat2','Dat3'};
Config = uitable('Units','normalized','Position',[0 0 0.2 0.4],...
            'Data', dat,... 
            'ColumnName', columnname,...
            'ColumnFormat', columnformat,...
            'ColumnEditable', columneditable,...
            'RowName',rowname);
cell2mat(dat(:,1:3));
gh =get(Config,'Data');

事前にアドバイスをありがとう

4

1 に答える 1

1

大きなことは、関数の最後で、テーブル データを出力に割り当てる前に、waitfor(gcf) が必要なことだと思います。

この例をチェックしてください:

function [out1]=myGUIwithATable(inputs..)

myTable=uitable(.......)

waitfor(gcf) 

%This command will wait until you close the GUI before doing the code after 
% it. We use this to allow you to enter all your data and whatnot, then once  
% you close the fig, it will execute your save commands

out1=get(myTable,'Data');

^^^ は、出力変数をテーブル値に割り当てる方法です

ボタンによる保存は非常に簡単です。ボタンのコールバックで、

save('fileName.mat',get(myTable,'Data'))

それが役立つことを願っています!

于 2013-06-26T14:13:55.787 に答える