function MTFgraph(maxfreq, age, p) %MTFgraph(maxfreq, age, p) Graphs a series of MTF functions in order to compare %them % if (nargin > 1) q = [0:1:maxfreq-1]; mtf = [0:1:maxfreq-1]; m = pigment; for i = 1:length(q) mtf(i) = MTFip(q(i), p, age, m); end plot(q, mtf) else numsubs = input('How many subjects would you like to compare (up to 4)'); for n = 1:numsubs switch n case{1} q1 = [0:1:maxfreq-1]; mtf1 = [0:1:maxfreq-1]; age1 = input('What is the age of the first subject?'); p1 = input('What is the pupil diameter (in mm)?'); m1 = pigment; for i = 1:length(q1) mtf1(i) = MTFip(q1(i), p1, age1, m1); end case{2} q2 = [0:1:maxfreq-1]; mtf2 = [0:1:maxfreq-1]; age2 = input('What is the age of the second subject?'); p2 = input('What is their pupil diameter (in mm)?'); m2 = pigment; for i = 1:length(q2) mtf2(i) = MTFip(q2(i), p2, age2, m2); end case{3} q3 = [0:1:maxfreq-1]; mtf3 = [0:1:maxfreq-1]; age3= input('What is the age of the third subject?'); p3 = input('What is their pupil diameter (in mm)?'); m3 = pigment; for i = 1:length(q3) mtf3(i) = MTFip(q3(i), p3, age3, m3); end case{4} q4 = [0:1:maxfreq-1]; mtf4 = [0:1:maxfreq-1]; age4 = input('What is the age of the fourth subject?'); p4 = input('What is their pupil diameter (in mm)?'); m4 = pigment; for i = 1:length(q4) mtf4(i) = MTFip(q4(i), p4, age4, m4); end end end switch numsubs case{1} plot(q1, mtf1) legend('Subject1') case{2} plot(q1,mtf1,q2,mtf2) legend('Subject1','Subject 2') case{3} plot(q1,mtf1,q2,mtf2,q3,mtf3) legend('Subject1', 'Subject2', 'Subject3') case{4} plot(q1,mtf1,q2,mtf2,q3,mtf3,q4,mtf4) legend('Subject1', 'Subject2', 'Subject3', 'Subject4') end end xlabel('spatial frequency(cpd)') ylabel('modulation transfer') title('Modulation Transfer Functions with varying age, pigmention, and pupil size')