Using uigetfile to select file in App Designer is causing the matlab script to open after file is selected

39 次查看(过去 30 天)
Hey everyone,
I am having some issues here and I'd greatly appreciate some help.
I am using uigetfile to let user select a type- file in App Designer, but once the file is selected, it goes back to matlab script, and not to the App GUI in app designer.
I have two different app functions for this. I have a BrowseFileNameButton (button), and I have FileName (which is a blank text field, to take the value of the Filename selected.
The below code works, and fills in the correct value that I want for FileName, but how do I get it to go back to the GUI screen after the browse folder box appears? Why does it keep going back to matlab script?
Thanks so much!
% Button pushed function: BrowseFileNameButton
function BrowseFileNameButtonPushed(app, event)
[fileName,filePath] = uigetfile('Test/Data/*.mat');
app.FileName.Value = [fileName,filePath];
end
  1 个评论
Geoff Hayes
Geoff Hayes 2021-9-29
Akana - I'm not too sure what you mean by it goes back to matlab script. What script? The above is BrowseFileNameButtonPushed seems to be just a callback for your button so you should still be "in" your GUI once the callback completes...and so the GUI should still respond to interactions with you (the user).

请先登录,再进行评论。

采纳的回答

Kevin Holly
Kevin Holly 2021-9-29
You can try this:
% Button pushed function: BrowseFileNameButton
function BrowseFileNameButtonPushed(app, event)
[fileName,filePath] = uigetfile('Test/Data/*.mat');
app.FileName.Value = [fileName,filePath];
drawnow;
figure(app.UIFigure)
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by