Passing variable from MATLAB APP Designer Edit Field to a variable inside a .m file.
42 次查看(过去 30 天)
显示 更早的评论
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 个评论
Stephen23
2022-11-14
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.
采纳的回答
Chris
2022-11-14
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
0 个评论
更多回答(2 个)
Vijay
2022-11-14
You can use ‘load’ function to load your desired variable from a matfile into workspace or a structure.
Here is more info on ‘load’ function Load variables from file into workspace - MATLAB load - MathWorks India.
Example:
S = load("matlab.mat"); %S is a structure
app.EditField.Value = S.myVar;
Hope this helps!
1 个评论
Walter Roberson
2022-11-14
They want the opposite. They want the edit field to change one of their variables.
Walter Roberson
2022-11-14
make x a property of the app. Have your callback do
app.x = app.x_valueEditField.Value;
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!