Hi, I'm not a great expert with uicontrols and more specifically with uibuttongroups and I need some help.
The thing is I've defined a buttongroup with three radiobuttons linked to it:
dpb = uibuttongroup('FontSize',12,'Position',[.015 .65 .17 .28]);u0 = uicontrol(dpb,'Style','radiobutton','String','P-130',... 'Position',[30 110 100 30],'BackgroundColor',[.8,.8,.8],'Tag','1');u1 = uicontrol(dpb,'Style','radiobutton','String','FAST',... 'Position',[30 65 100 30],'BackgroundColor',[.8,.8,.8],'Tag','2');u2 = uicontrol(dpb,'Style','radiobutton','String','SLOW',... 'Position',[30 20 100 30],'BackgroundColor',[.8,.8,.8],'Tag','3');
Then I added some properties to the uibuttongroup:
set(dpb,'SelectedObject',[]); % No selection
set(dpb,'SelectionChangeFcn',@dpbcbk); %Deceleration profile's callback
In other part of my script I've created a edit uicontrol (pdp is a uipanel which is parented to) that I want to be updated with a given value depending on the user selection of the aforementioned uibuttongroup:
edt4 = uicontrol(pdp,'Style','edit','Position',[330 200 80 20]);
My problem is to define properly the callback function to get this done. I've tried it (although to no avail) with the following callback:
function dpbcbk(source,eventdata)switch get(eventdata.NewValue,'tag') case '1' set(edt4,'String','130'); case '2' set(edt4,'String','150'); case '3' set(edt4,'String','110'); end
This are the error messages I get:
Undefined function or variable 'edt4'.Error in dpbcbk (line 8) set(edt4,'String','110');Error in hgfeval (line 63) feval(fcn{1},varargin{:},fcn{2:end});Error in uitools.uibuttongroup/childAddedCbk>manageButtons (line 79) hgfeval(cbk, source, evdata);
I know that there is something that I'm missing, but I don't know much about how to work with callbacks. Any input is welcome.
Best Answer