nav-left cat-right
cat-right
Matthias Pospiech > Articles by: pospiech

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', handles.radiobuttonPlotROI); set(handles.uibuttongroupView, 'SelectionChangeFcn',@uibuttongroupView_SelectionChangeFcn); The callback function then looks like function...

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 be saved under a different folder it needs to be created and the file name changed accordingly [filepath, filename, ext] =...

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 variable with persistent. function popupmenuAlgorithm_Callback(hObject, eventdata, handles) % hObject handle to popupmenuAlgorithm (see GCBO) %...

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'; set(handles.popupmenuColorMap, 'String',colormapStr,'value',1);   % get current selection of menu ColorMapContents =...
Page 4 of 28« First...23456...1020...Last »