img = 1:300;
mp = spectrum(301);
image(img);
colormap(mp);


imageR = ones(100, 730-430+1);
imageG = imageR;
imageB = imageR;
for wavelength = 430:730
	index1 = wavelength-430+1;
	index2 = 730-wavelength+1;
	imageR(:,index1) = mp(index2,1);
	imageG(:,index1) = mp(index2,2);
	imageB(:,index1) = mp(index2,3);
end

[X2 map] = rgb2ind(imageR, imageG, imageB, 256);
figure, imshow(X2, map);
imwrite(X2, map, 'rainbow3.bmp', 'bmp')


colorR = imageR; colorG = imageG; colorB = imageB;
save 'colorRGB.mat' colorR colorG colorB;
