Passing variable from MATLAB APP Designer Edit Field to a variable inside a .m file.

Currently I am able to create a GUI in the Matlab App Designer and I want to connect some of the input edit field value to some variable inside a .m file. How do I do that?
GUI:
function x_valueEditFieldValueChanged(app, event)
value = app.x_valueEditField.Value;
end
.m File:
want the variable x to be what the user input to be

댓글 수: 3

Chris
Chris 2022년 11월 12일
편집: Chris 2022년 11월 12일
Is the .m file meant to be called/run by the GUI, or by something else?
Yes, the .m file is meant to be called by the GUI.
Why not just call the function and pass that data as an input argument?
That would be by far the simplest and most efficient approach.

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

 채택된 답변

m-file:
function myFun(x)
disp(x);
end
GUI:
Properties
x
end
function x_valueEditFieldValueChanged(app, event)
app.x = app.x_valueEditField.Value;
myFun(app.x);
end

추가 답변 (2개)

You can use ‘load’ function to load your desired variable from a matfile into workspace or a structure.
Example:
S = load("matlab.mat"); %S is a structure
app.EditField.Value = S.myVar;
Hope this helps!

댓글 수: 1

They want the opposite. They want the edit field to change one of their variables.

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

make x a property of the app. Have your callback do
app.x = app.x_valueEditField.Value;

카테고리

도움말 센터File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

태그

질문:

2022년 11월 11일

답변:

2022년 11월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by