App/GUI tutorials

3 views (last 30 days)
Rick Verberne
Rick Verberne on 17 Jul 2018
Answered: Rik on 17 Jul 2018
Hi all, As a bit of noob in the world of programming, I stumbled across an opportunity to create an App or GUI usefull for my field of study. Now, I'm capable of writing scripts that will lead to the required answers, however this is not suitable for distribution. Second problem is that I don't have enough spare time to learn it the hard way by trial and error. Therefor I was hoping to find a good guide, tutorial or package of courses and lessons that could kickstart this. So does anyone has recommendation for this? Best,
Rick

Accepted Answer

Rik
Rik on 17 Jul 2018
Using GUIDE held me back for a long time, so below you'll find my advice on what to do when not using GUIDE. For distribution, it is important to know if the people using your GUI have Matlab, or if they're allowed to install the MCR. As an alternative you could consider making your code compatible with Octave, but that will have a load of downsides on it's own.
My small guide to avoid GUIDE:
  • 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.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!