How to you store data into an array by clicking an button in MATLAB App designer?

조회 수: 24 (최근 30일)
Gooday,
I would like some assistance in creating a code for storing multiple variables in an array when the user presses a "Pushbutton". For example when a user enters two numberic values into the application. The application then calculates the area of the room and I would like application to allow the user to store the three variables ( length_of_room, Width_of_room and Area_of_room) into and array. Any assistance is appreciated. Thank you
  댓글 수: 3
Rik
Rik 2022년 2월 3일
For general advice and examples for how to create a GUI, have look at this thread.
Kyle Ramphal
Kyle Ramphal 2022년 2월 3일
Thank you both for the information. I would look at the resources listed and give it a try.

댓글을 달려면 로그인하십시오.

채택된 답변

Shanmukha Voggu
Shanmukha Voggu 2022년 3월 11일
Hi Kyle,
I understood you want to calculate the area from the two numeric inputs given and use it.
To do this, we can create three edit fields corresponding to length, breadth, and area of the room. An additional button is created in which the click on button will calculate the area from the length, breadth edit fields and update the area in the corresponding edit field.
In the above app, The call back of the "calculate area" button is as follows
% Button pushed function: calculateareaButton
function calculateareaButtonPushed(app, event)
length=app.lengthEditField.Value; % get value in length edit field
breadth=app.breadthEditField.Value; % get value in breadth edit field
area=length*breadth; % calculate area
app.AreaEditField.Value=area; % update area edit field
x=[length, breadth, area]; % store all the details in the array
end
I have attached the app implementing the workflow that I mentioned above.
Refer to below documentation link for more information:
Hope this helps!

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop 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