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

15 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

Kevin Holly
Kevin Holly le 4 Avr 2022
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.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by