How can I make the browse pushbutton on my GUI in Matlab functional?

Code:
FileName = 'kWilliams.txt';
FileName;FilePath = uigetfile();
ExPath = [FilePath FileName];
Currently, it opens up the windows gui that "select file to open". However, when I try to select a file and open the file everthing just disappears

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 3 日

1 投票

[FileName,FilePath ]= uigetfile();
ExPath = fullfile(FilePath, FileName)

5 件のコメント

Cordelle
Cordelle 2013 年 6 月 3 日
Thank you for the code, but everything still disappears once I try to open a selected file.
I am trying to have the user select a file and have the name of the file the user selected appear in the text box next to the browse button.
I am trying to at least be able to open the file that the user selected using my browse button
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 3 日
Post the code you are using?
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 3 日
[FileName,FilePath ]= uigetfile();
ExPath = fullfile(FilePath, FileName)
set(handles.edittext1,'string',ExPath)
Cordelle
Cordelle 2013 年 6 月 3 日
編集済み: Azzi Abdelmalek 2013 年 6 月 3 日
% Browse button code
% --- Executes on button press in Browse1.
function Browse1_Callback(hObject, eventdata, handles)
% hObject handle to Browse1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName,FilePath ]= uigetfile();
ExPath = fullfile(FilePath, FileName);
(I would like have the file selected from the browse button appear in the text box next to it, just to show the user that the computer has obtained the correct file; for example, like attaching a file to an email.)
%textbox code
function Filename1_Callback(~, ~, ~)
function Filename1_CreateFcn(hObject, ~, ~)
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 6 月 3 日
function Browse1_Callback(hObject, eventdata, handles)
[FileName,FilePath ]= uigetfile();
ExPath = fullfile(FilePath, FileName);
set(handles.Filename1,'string',ExPath)

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

その他の回答 (1 件)

Emanuel
Emanuel 2015 年 5 月 4 日

0 投票

Hello, I want now to simulate the browsed file (.mdl) with a push button. what command do I use? set_param(' ??? ,'SimulationCommand','start'); thanks for the information

カテゴリ

ヘルプ センター および File ExchangeApp Building についてさらに検索

質問済み:

2013 年 6 月 3 日

回答済み:

2015 年 5 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by