[Appdesigner] table that is calculated by the user input data
Mostrar comentarios más antiguos
Hi.
I am going to make an app using Matlab’s app designer.
The app will consist of one NumEditField, two Tables (A, B), one result window, and two buttons (Make Table, Calculate).
First, enter a number in the NumEditField and press the Make Table button, then a 3 x n size table A and a 5 x n size table B should be created.
At this time, the data of tables A and B should be able to be entered by the user.
After the user enters all the data for A and B, when the Calculate button is pressed,
I want the value calculated by the Inout_Function(A_1, A_2, A_3, B_1, B_2,B_3, B_4, B_5) function to be displayed through the result window.
Thank you.

1 comentario
Mario Malic
el 20 de Sept. de 2023
What stops you in making the app?
Respuestas (1)
prabhat kumar sharma
el 25 de Sept. de 2023
Hi @민준 장
I understand you are facing the problem with app designer UITable.
And I have have designed a similar solution by keeping your requirement in mind. Please find the stepwise solution below.
- Open MATLAB and click on the "App Designer" button in the "APPS" tab.
- In the App Designer window, drag and drop the following components from the "Component Library" to the app canvas:
- One NumEditField (rename it to "numEditField")
- Two Tables (rename them to "tableA" and "tableB")
- One Result window (e.g., a TextArea component, rename it to "resultWindow")
- Two Buttons (rename them to "makeTableButton" and "calculateButton")
Set the properties of the components as follows:
- For the "makeTableButton", set the "Text" property to "Make Table".
- For the "calculateButton", set the "Text" property to "Calculate".
Write the below functionalities according to your requirement.
function MakeTableButtonPushed(app, event)
n = app.numEditField.Value;
app.tableA.Data = zeros(n, 5);
app.tableB.Data = zeros(n, 3);
app.tableA.ColumnEditable = true(1,5);
app.tableB.ColumnEditable = true(1,3);
end
% Button pushed function: calculateButton
function calculateButtonPushed(app, event)
A = app.tableA.Data;
B = app.tableB.Data;
result = Inout_Function(app,A,B);
app.resultWindowTextArea.Value = num2str(result);
end
and we have to add a new private function for the InOut Function you want.
methods (Access = private)
function results = Inout_Function(app,A,B)
temp = sum(A,"all");
results = temp + sum(B,"all");
end
end

Categorías
Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!