From: Jose on
Hello guys, I have the next panel with 4 states: Start, Stop, Pause and Continue,
this is the code:

Figure=figure(100);

h = uibuttongroup('visible','off');

u(1)=uicontrol('Parent',h,'Style','togglebutton','String','Start','pos',[0 250 100 100])
u(2)=uicontrol('Parent',h,'Style','togglebutton','String','Stop','pos',[150 250 100 100])
u(3)=uicontrol('Parent',h,'Style','togglebutton','String','Pause','pos',[300 250 100 100])
u(4)=uicontrol('Parent',h,'Style','togglebutton','String','Continue',[450 250 100 100])


set(h,'SelectionChangeFcn',@blk);
set(h,'SelectedObject',[]); % No selection
set(h,'Visible','on');

%................................

function blk(h,event)
hUi=get(h,'SelectedObject')
Val=get(hUi,'String')


My question is:

I want to call to a differentes functions, called x1, x2, x3 and x4...depending of the value of Val I get: Start, Stop, Pause or Continue, and I am thinking of doing it with..(if )commands like:

if Val =1....then call x1

if Val =2...then call x2

Maybe, another possibility is keep the val like a String, but I do not know how I can do it...if Val='Start'...? I am not idea.

Thnaks in advance,

Jose.
From: Matt Fig on
Look at using a SWITCH instead. A switchyard can replace many consecutive IF statements or chained IF-ELSE statements.
From: Jose on
Thank you very much Matt.
It was exactly like I was looking for.
Cheers.
Jose.



"Matt Fig" <spamanon(a)yahoo.com> wrote in message <hfupa0$n8g$1(a)fred.mathworks.com>...
> Look at using a SWITCH instead. A switchyard can replace many consecutive IF statements or chained IF-ELSE statements.