% ***********************************************************************
% F2.m
% ***********************************************************************
%
% Data description:
% Relative spectral power distribution of a standard illuminant F2
%
% Prepared by: Spencer Van Leeuwen on May 2017
%
% ***********************************************************************
%
% Original data source:
%     R. W. G. Hunt. Measuring Colour, 2nd ed.
%     Ellis Horwood Limited, Chichester, 1991.
%
% ***********************************************************************

data = [380, 1.18
                  385, 1.48
                  390, 1.84
                  395, 2.15
                  400, 3.44
                  405, 15.69
                  410, 3.85
                  415, 3.74
                  420, 4.19
                  425, 4.62
                  430, 5.06
                  435, 34.98
                  440, 11.81
                  445, 6.27
                  450, 6.63
                  455, 6.93
                  460, 7.19
                  465, 7.40
                  470, 7.54
                  475, 7.62
                  480, 7.65
                  485, 7.62
                  490, 7.62
                  495, 7.45
                  500, 7.28
                  505, 7.15
                  510, 7.05
                  515, 7.04
                  520, 7.16
                  525, 7.47
                  530, 8.04
                  535, 8.88
                  540, 10.01
                  545, 24.88
                  550, 16.64
                  555, 14.59
                  560, 16.16
                  565, 17.56
                  570, 18.62
                  575, 21.47
                  580, 22.79
                  585, 19.29
                  590, 18.66
                  595, 17.73
                  600, 16.54
                  605, 15.21
                  610, 13.80
                  615, 12.36
                  620, 10.95
                  625, 9.65
                  630, 8.40
                  635, 7.32
                  640, 6.31
                  645, 5.43
                  650, 4.68
                  655, 4.02
                  660, 3.45
                  665, 2.96
                  670, 2.55
                  675, 2.19
                  680, 1.89
                  685, 1.64
                  690, 1.53
                  695, 1.27
                  700, 1.10
                  705, 0.99
                  710, 0.88
                  715, 0.76
                  720, 0.68
                  725, 0.61
                  730, 0.56
                  735, 0.54
                  740, 0.51
                  745, 0.47
                  750, 0.47
                  755, 0.43
                  760, 0.46
                  765, 0.47
                  770, 0.4
                  775, 0.33
                  780, 0.27];

fid=fopen('f2.txt','wb');
for i=1:length(data)
    fprintf(fid,'%d  %3.4f \n',data(i,1),data(i,2));
end
fclose(fid);

plot(data(:,1), data(:,2), 'b', 'linewidth',1.5);
title('F2','FontSize',14);
set(gca,'FontSize',14);
ylabel('relative spectral power distribution','fontsize',14);
xlabel('wavelength (nm)','fontsize',14);
set(gcf,'PaperUnits','inches','PaperPosition',[0 0 6 5]);
axis([380 780 0 40]);
grid on;

pause;
print -dpng f2.png -r100
close;
