MATLAB: How to get RGB data from a webcam

rgbspectrometer

I'm making a program that is gonna represent the data from the diffracted light from a spectrometer into an interactive graph, using Matlab.
clear('cam');
cam = webcam(1);
fig = figure('NumberTitle','off','MenuBar','none');
fig.Name = 'Spektrum';
ax = axes(fig);
frame = snapshot(cam);
im = image(ax,zeros(size(frame),'uint8'));
axis(ax,'image');
preview(cam,im)
This is the code I have so far, however I don't know how to get the RGB data from the webcam and plot it in a graph, which is my problem.
Thanks in advance.