Driving data from GUI application to the matlab script
조회 수: 2 (최근 30일)
이전 댓글 표시
I am building a GUI application using App Designer. A button on the GUI invokes .m script(through callback) that has certain variables hard-coded and are used for the
execution of the script. These are the same variables I would want to drive through GUI(edit number field) to let the user decide the values and see the impact in results.
Let's say X is a variable within .m script and I want to change it through GUI. Tried this:
In .m script:
-------------
Before X is defined, added below line
app = app1; (app1 is the name of my GUI Application)
X = app.y; (where y is defined as a public property with no default values assigned in the GUI application)
In GUI application:
------------------
properties (Access = public)
y
end
function buttonPushed(app,event)
app.y = app.X_EditField.Value; (X_EditField is created as an entry using the Edit Field(Numeric) from Component Library)
run ('<.m>')
end
What am I doing wrong?
댓글 수: 0
답변 (1개)
Yongjian Feng
2021년 11월 18일
Why don't you create your matlab script as a function and then take y as an input argument?
function foo(y):
% whatever your script needs to do with y
end
Put this function in the same location of your app or in a folder of matlab path, then in your app you can just call it
foo(y);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Compiler에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!