How to call a script when clicking on a button in matlab app.designer?
조회 수: 17 (최근 30일)
이전 댓글 표시
I am trying to do the following app:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/488153/image.png)
In which, when clicking on the button, a script is executed and its numerical calculations performed and its result appears in the white window
I have defined as private property the following variables with those values.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/488158/image.png)
So when the button is clicked, the script (which name is: operasion.m) is called and the result (j) appears on the white window
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/488163/image.png)
The script is the following
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/488168/image.png)
Thank you very much for the help. By the way, the script.m and the app are saved in the same folder
댓글 수: 0
채택된 답변
Cris LaPierre
2021년 1월 14일
You run a script by calling it by name.
However, is there a reason you don't just include the code and parameters inside your app? It seems unnecessary to have this code in an external m file.
app.solu.Value= app.a + app.b;
댓글 수: 8
Cris LaPierre
2021년 1월 14일
At least based on the original example you don't have to do j=app.j since j is calculated in the script. If you want to save the value in your app, you probably want to do the opposite.
app.j = j;
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File 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!