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

17 ビュー (過去 30 日間)
Akana Juliet
Akana Juliet 2021 年 9 月 29 日
コメント済み: Akana Juliet 2021 年 9 月 29 日
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
  1 件のコメント
Akana Juliet
Akana Juliet 2021 年 9 月 29 日
It worked, this is exactly what I needed. Thanks so much!

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by