Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to create GUI

2 ビュー (過去 30 日間)
snehal sule
snehal sule 2019 年 2 月 22 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I want to create GUI in which I have to display the image which showed in function file of main code.How to display that image in gui axes?
  2 件のコメント
Stephen23
Stephen23 2019 年 2 月 22 日
doc image
Rik
Rik 2019 年 2 月 22 日
For how to display an image in an axes object, use the command Stephen gave you.
For how to create a GUI:
  • Make a figure (with f=figure;) and look into the doc for figure which properties you want to turn off (you probably want to set Menu and Toolbar to 'none')
  • Create buttons and axes and everything you need with functions like uicontrol and axes. Save the handles to each element to fields of a struct (like handles.mybutton=uicontrol(___);)
  • When you've finished loading all data (and saving it to fields of your handles struct), and creating all the buttons, save your handles struct to the guidata of your figure like this guidata(handles.f,handles);. (You can also use getappdata and setappdata)
  • You can set the Callback property of many objects. If you do, use a function name with an @ in front, or a char array that can be evaluated to valid code. (like @MyFunction or 'disp(''you pushed the button'')')
  • Callback functions will be called with two arguments: the first is a handle to the callback object, the second is eventdata that may contain special information. To get access to your data, just use handles=guidata(gcbo);. You can replace the gcbo function with the name of the first input to your callback function if you prefer.
  • More information about callbacks can be found in multiple places in the doc, for example here.

回答 (1 件)

Cris LaPierre
Cris LaPierre 2019 年 4 月 9 日
編集済み: Cris LaPierre 2019 年 4 月 9 日
If you've never used Guide before, I recommend using app designer.
Here's some sample code that can help you out.

Community Treasure Hunt

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

Start Hunting!

Translated by