Converting Gamut3D from RGB colorspace to LAB colorspace
The so-called Gamut in the code, is nothing but a 3d color histogram. Colors from the image are collected into it, and then each unique (r,g,b) is being shown as a scatter point.

In order to show the distribution of the colors in LAB space, you can convert your image from sRGB to LAB, (Assuming that the image is in sRGB space) and then run the same procedure that you have now.

In order to convert it, use:

    cform = makecform('srgb2lab');
    labImage = applycform(cform, rgbImage);




By the way, the code in your question can be optimized into 4 lines:

    im = imread('peppers.png');
    im = reshape(im,[],3);
    im = unique(im,'rows');
    scatter3(im(:,1),im(:,2),im(:,3));