Why am I having trouble transferring a folder path from a matlab app to script?

Here is my app code, I used a button to import the folder path.
% Button pushed function: ImportButton
function ImportButtonPushed(app, event)
%[filename,path] =uigetfile();
%app.FilenameEditField.Value=filename;
%figure(app.UIFigure);
folder= uigetdir()
app.FilenameEditField.Value = path;
figure(app.UIFigure);
end
Here is the code I used to run my app in my script and get the variable containing the folder path
appHand = uiginterface;
myData = appHand.UITable.folder
When I run this code the app opens, however the my Data executes before folder has been obtained and gives me an empty value.

Antworten (1)

Suvansh Arora
Suvansh Arora am 1 Dez. 2022
In order to wait for a statement to complete its execution before moving ahead in your app, I would recommend using “waitfor” in MATLAB, please follow the documentation mentioned below for more details: watifor documentation
If this doesn’t resolve the issue, please help me with the following information:
  • “.m” script that I can use to reproduce this issue, as in the attached code, the “app” is not defined and there is no call to the importButtonPushed.
I hope the above information helps you.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2022a

Gefragt:

am 28 Nov. 2022

Beantwortet:

am 1 Dez. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by