waitbar with cancel button

The following code is an example for a loop function with a waitbar that allows canceling of the loop with the cancel button: Note however that a waitbar consumes very much time. Depending on the code this can slow down the calculation significantly. if numel(indices)...

radiobuttons in a buttongroup

In matlab one has to place radiobuttons in a uibuttongroup to make them exclusively selectable. In the startup of the gui one can select the default selection and define a callback function set(handles.uibuttongroupView, ‘SelectedObject’,...

enable zoom in gui

Matlab provides the function of making axes zoomable in a gui (zoom reference). In a matlab gui this is enable by using this code: hZoom = zoom; setAllowAxesZoom(hZoom,handles.axes,true);...

change extension of filename

Very often I tend to save the results of a file under the same name, but with a modified extension. This code shows how to achieve this % change extension [~, ~, ext] = fileparts(FileName); FileName = strrep(FileName, ext, ‘-xyz.png’); If the file should...

check if gui selection has changed

The callback of an ui element is called whenever the element has been modified. However this does not necessarily mean that the value of the element has changed. Here is an example where an action is only performed if the value has changed. The trick is to use a value...

matlab popupmenu (combobox)

The popupmenu of the matlab gui is based on the uicontrol class. Below is a sample code for its usage: % create text entries in menu colormapStr{1}= ‘blue-red’; colormapStr{2}= ‘red-blue’; colormapStr{3}= ‘gray’;...