function RGBValues = xyz2rgb(XYZValues)
% RGBValues = xyz2rgb(XYZValues)
% Converts XYZ values to RGB values assuming some standard phosphors.
%
%   RGBValues = nx3 matrix of RGB values
%
%   XYZValues = nx3 matrix of XYZ values

% Create RGB-to-XYZ transformation
monitorData = load('monitor.mat');
phosphors = monitorData.phosphors;
XYZData = load('XYZ.mat');
XYZ = XYZData.data;
RGB2XYZ = XYZ.' * phosphors;
XYZ2RGB = inv(RGB2XYZ);

% Transform input XYZ values to output RGB values
RGBValues = (XYZ2RGB * XYZValues.').';

