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

43 Ansichten (letzte 30 Tage)
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 Kommentare
Stephen23
Stephen23 am 14 Nov. 2022
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Chris
Chris am 14 Nov. 2022
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

Weitere Antworten (2)

Vijay
Vijay am 14 Nov. 2022
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!

Walter Roberson
Walter Roberson am 14 Nov. 2022
make x a property of the app. Have your callback do
app.x = app.x_valueEditField.Value;

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by