필터 지우기
필터 지우기

Driving data from GUI application to the matlab script

조회 수: 2 (최근 30일)
Shyam Vudata
Shyam Vudata 2021년 11월 18일
답변: Yongjian Feng 2021년 11월 18일
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?

답변 (1개)

Yongjian Feng
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);

카테고리

Help CenterFile Exchange에서 MATLAB Compiler에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by