MATLAB: Load a variable from base workspace into a edittext field

app designer

I have a a function called DataCollector.m The function opens the file explorer using
[FileName,PathName] = uigetfile('*.lcm','Select the MATLAB code file');
Which is in the DataCollector.m file.
So i would like to take the parameter FileName and display it in a edit text field. So i have written
app.EditField.Value = FileName;
Which does not work. How do i solve this?

Best Answer

I solved it by making the variable FileName global in the .m file.