how to capture an image using usb webcamera in matlab

code 
imaqhwinfo
imaqhwinfo('winvideo')
imaqhwinfo('winvideo',1)
vid = videoinput('winvideo',1,'RGB24_640x480');
frame=getsnapshot(vid);
imshow(frame)