This matlab function will turn a radiance spectrum into an red-green-blue (RGB) color using the cie conversion. It also provides the CIE chromaticity coordinates and the luminosity of the spectrum.


This code will create a continuous rainbow with colors going from 380-750 nm. I found the code somewhere on the web and made it matlab friendly. It doesn’t use CIE tristimulus function, but makes the rainbow by gradually increasing the RGB values over ranges.