function myButtonRandColor

%% function generating GUI and defines callback function
figure('MenuBar','none','Position',[500 500 500 50])
hndlB = uicontrol('Style','pushbutton','FontSize',11,...
    'FontWeight','bold','ForegroundColor','k','Units','normalized',...
    'Position',[0.5 0.0 0.5 1],'BackgroundColor','y',...
    'String','my button');
hndlT = uicontrol('Style','text','FontSize',11,...
    'Units','normalized','Position',[0 0 0.5 1],...
    'String','Yellow');
 
set(hndlB,'Callback',@(scr,event)changeColor(hndlB,hndlT));
end 

function changeColor(handleB,handleT)
%% callback function > carried out operation after button click
    Color = rand(1,3);
    set(handleB,'BackgroundColor',Color);
    set(handleT,'String',sprintf('[R:%0.4f, G:%0.4f,B:%0.4f]',Color));
end
