GUI Pushbutton, accessing another file
6 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am fairly new to matlab, and attempting to make a basic GUI that has two pushbuttons, along with some other things. My question relates to the pushbuttons. I am wondering how to write the code so that when the user clicks a pushbutton, it opens up another file.
So, matlab automatically brings up:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
and I am wondering where I put in code to allow the pushbutton, when clicked, to open up my other m file?
Cheers~
0 件のコメント
採用された回答
Matt Fig
2011 年 2 月 23 日
Do you mean that your file is hardcoded into the GUI? If so, put this in the pushbutton callback:
edit mfilename
where you replace mfilename with the name of your M-File.
If the file is not in the current directory, you will have to add the path.
If that is not what you meant, you might want to use UIGETFILE instead:
[fnam,pth] = uigetfile('*m')
edit([pth fnam])
6 件のコメント
Matt Fig
2011 年 2 月 25 日
I recommend you select a best answer for this thread, then start a new one because this is a new topic.
その他の回答 (1 件)
Paulo Silva
2011 年 2 月 25 日
fig=figure
uicontrol('Style','pushbutton','String','Start',...
'Callback','SomeMFileNameIWantToOpen',...
'Units','Normalized','Position',[0.5 0.5 0.1 0.1],...
'Parent',fig)
2 件のコメント
Matt Fig
2011 年 2 月 25 日
He is using GUIDE...
And this is not advisable if there could be more than that simple call to run the other M-File in the callback.
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!