How to sum a specific column in the UI Table Component using MATLAB App designer?

6 ビュー (過去 30 日間)
How to calcualate the sum of a specified column with a UI table Componment in MATLAB Appdesinger. The UI table is integrated with the struct function to store the data. Please see the attached code file to see the approached taken. Firstly the user enters the two values by clicking the submit button and storing it into the UI table. The user then should beable to press the display button to see the total of a specific colum when chosen from the drop down menu component. Any assistance would be appreciated.

採用された回答

Kevin Holly
Kevin Holly 2022 年 4 月 4 日
Please see the edited app attached.
I changed the following functions:
function tablefcn(app)
% d2struct = struct('num',app.num1,'num2',app.num2);
% dg1 = struct2cell(d2struct);
app.UITable.Data = [app.t1;[app.num1,app.num2]];%dg1'];
app.t1 = app.UITable.Data;
end
function sumvalue1(app) % function to sum the columns
app.total = sum(app.t1);
app.TotalEditField.Value= app.total(1);
end
function sumvalue2(app)
app.total = sum(app.t1);
app.TotalEditField.Value= app.total(2);
end
I also deleted a space in your dropdown box for 'Value 1', it was 'Value 1 '. The space was causing the case to not be identified.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by