MATLAB: GUI: OpeningFcn problem

guiopeningfcnradiobutton

Hey there! I'm encountering a little problem with my GUI.
Goal: 3 panels disabled by default (when I open the GUI figure) and one of them enables when I select one of three radio buttons.
Problem: This works perfectly well when I run my GUI.m code but it shows an error when I try it by opening the GUI.fig.
OpeningFcn:
function GUI_OpeningFcn(hObject, eventdata, handles, varargin)
set(findall(handles.panel1,'-property','enable'),'enable','off');
set(findall(handles.panel2,'-property','enable'),'enable','off');
set(findall(handles.panel3,'-property','enable'),'enable','off');
handles.output = hObject;
guidata(hObject, handles);
SelectionChangeFcn:
function RadioPanel_SelectionChangeFcn(hObject, eventdata, handles)
switch hObject
case handles.radiobutton1
set(findall(handles.panel1, '-property', 'enable'), 'enable', 'off');
set(findall(handles.panel2, '-property', 'enable'), 'enable', 'off');
set(findall(handles.panel3, '-property', 'enable'), 'enable', 'on');
case handles.radiobutton2
set(findall(handles.panel1, '-property', 'enable'), 'enable', 'on');
set(findall(handles.panel2, '-property', 'enable'), 'enable', 'off');
set(findall(handles.panel3, '-property', 'enable'), 'enable', 'off');
case handles.radiobutton3
set(findall(handles.panel1, '-property', 'enable'), 'enable', 'off');
set(findall(handles.panel2, '-property', 'enable'), 'enable', 'on');
set(findall(handles.panel3, '-property', 'enable'), 'enable', 'off');
end

Best Answer

Sébastien - GUIs cannot be run by double-clicking on the figure (.fig) file. They are only meant to be run from the GUIDE GUI editor, the m-file editor, or by calling the GUI m-file name from the Command Window.
From http://www.mathworks.com/help/matlab/creating_guis/files-generated-by-guide.html, a FIG-file, with extension .fig, contains a complete description of the UI layout and each UI component, such as push buttons, axes, panels, menus, and so on. The FIG-file is a binary file and you cannot modify it except by changing the layout in GUIDE. FIG-files are specializations of MAT-files.
Launching the GUI by double-clicking on the fig file just shows you the layout of the GUI but does not have any of the functionality.