MATLAB: Talking vending machine

display command on panelguipushbuttonvending machine

I'm current doing my final year project in Talking vending machine for blind, its full software project. How do i set command for each push button. Let say when the user press pushbutttonA the panel should diplay the name of the item and say it out at the same time. I know i have save the voice in wav file but i don't know how to execute the voice when the pushbutton is pressed. Can anyone help me in this. Its very helpful for me.
Thank in advance Sharmen

Best Answer

If you are using GUIDE to build your GUI you just drag a button to the fig, click on the button with the mouse right button, view callback and select callback, matlab will show you the code that is executed when you press the button, insert the code you want to perform in there.
If you aren't using guide (doing all in a m file), you could just do this
fig=figure;
uicontrol('Style','pushbutton','String','Start',...
'Callback','disp(''You pushed the button'')',...
'Units','Normalized','Position',[0.5 0.5 0.1 0.1],...
'Parent',fig)
or
function samplegui
fig=figure;
uicontrol('Style','pushbutton','String','Start',...
'Callback',@pressingthebutton,...
'Units','Normalized','Position',[0.5 0.5 0.1 0.1],...
'Parent',fig)
function pressingthebutton(a,b)
disp('You pushed the button')
end
end