Get the RGB color of monochromatic light
MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
RGB::fromWaveLength( λ ) returns an approximative
RGB specification for light of wavelength λ nm.
Light consists of photons, each of which has a distinct wavelength.
These different wavelengths cause color perception.
an RGB triple corresponding to a given wave length.
Different displays show the same RGB color in slightly different
ways. For this reason, the so-called “gamma correction” has been invented.
a second argument, for fine-tuning the assumed gamma correction that
enters the calculation.
Color perception depends on a number of factors, including individual
differences. Therefore, such a calculation can only return an approximation.
the model published by Dan Bruton for the conversion.
For wavelengths outside the visible spectrum (which ranges from 380 nm to 780 nm),
White light, when sent through a prism, is split into the commonly
known spectrum, because the prism refracts different wavelengths differently.
This spectrum can easily be reproduced by
plot(plot::Raster([[RGB::fromWaveLength(i) $ i=380..780]]), Scaling = Unconstrained, Height = 20)
Bruton's conversion model looks like this:
plotfunc2d( plot::Raster([[RGB::fromWaveLength(i) $ i = 380..780]], x = 380..780, y = -0.2..0), (x -> RGB::fromWaveLength(x)[i]) $ i = 1..3, x = 380..780, Colors = [RGB::Red, RGB::Green, RGB::Blue], LegendVisible = FALSE, XTicksNumber = Low, Scaling = Unconstrained, Axes = Automatic)
The wavelength: a real-valued constant (interpreted as nanometers) or a length unit
The “gamma correcture” for the display, defaults to 0.8
RGB color: a list of three floating-point values