フィルターのクリア

Modifying uitable using GUIDE

1 回表示 (過去 30 日間)
Kah Joon Yong
Kah Joon Yong 2015 年 10 月 2 日
コメント済み: Kah Joon Yong 2015 年 10 月 5 日
I would like to create a Table with default only 1 row and the user can add or delete a row using push buttons. The add and delete part is ok but the table created always stuck at 4 rows. No matter how I change the settings in the Inspector. Besides that I would also do some calculations in the last column cells. How can I customize that?

採用された回答

Geoff Hayes
Geoff Hayes 2015 年 10 月 3 日
In the OpeningFcn of your GUI, just set the Data property of the uitable to be a 1x2 (or whatever number of columns) cell array. Something like the following should work
% --- Executes just before untitled is made visible.
function myGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% Choose default command line output for untitled
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% set the table size to be 1x2
set(handles.uitable1,'Data',cell(1,2));
The above was tested with R2014a.
As for customization for calculations in the last column, please be more specific.
  3 件のコメント
Image Analyst
Image Analyst 2015 年 10 月 3 日
You have to get the data
yourData = get(handles.uitable1,'Data');
Then sum up the first few columns and put them in the last column
theSums = sum(yourData(:, end-1), 2);
yourData(:,end) = theSums;
% Send the new data back into the uitable.
set(handles.uitable1,'Data', yourData);
Kah Joon Yong
Kah Joon Yong 2015 年 10 月 5 日
Thank you Image Analyst. I will try it out. It seems like easy enough. Though I have tried this out and it works.
data = get(handles.Items_Detail, 'data');
sub = cell2mat(data(:,2))*cell2mat(data(:,3));
[row,~]=size(sub);
data(:,4)=mat2cell(sub,row);
set(handles.Items_Detail,'data',data);
It seems like the data in my table is in 'cell array' format and I could not add those values together using the normal 'plus' sign.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by