%Chapter 7,  Fig 7.5
%Eric Dubois, updated 2018-12-12
% Plot the CIE 1931 XYZ color matching functions 
% data files obtained from CVRL website
%Data files should be placed in a data directory on the MATLAB path.
clear all, close all;
%read the CIE 1931 XYZ color matching functions.
%they are defined from 360 nm to 830 nm in steps of 1 nm.
xyz = dlmread('data/ciexyz31_1.txt',',');
%plot the xyz color matching functions
figure;
lamxyz = xyz(:,1);
plot(lamxyz, xyz(:,2),'k',lamxyz, xyz(:,3),'k', lamxyz, xyz(:,4),'k');
xlabel('Wavelength (nm)');
ylabel('Tristimulus values');
text(450,.4,'x'), text(550, 1.1, 'y'), text(620,1,'x'), text(470,1.7,'z');
set(gcf,'Color',[1 1 1]);
set(gca,'fontname','times')          %set the plot font to Times