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

조회 수: 12 (최근 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 CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by