Don't know what is missing or wrong with my function.
Question asked to write a function called generationXYZ that takes as its only input argument one positive integer specifying the year of birth of a person and returns as its only output argument the name of the generation that the person is part of ('X', 'Y', or 'Z ') according to the table below.For births before 1966, return 'O' for Old and for births after 2012, return 'K' for Kid . Remember that to assign a letter to a variable, you need to put it in single quotes, as in: gen = 'X'.
Generation Born
X 1966-1980
Y 1981-1999
Z 2000-2012
This is my solution:
function gen = generationXYZ(a)if a < 1996 gen = 'O';elseif a >= 1996 && a <= 1980 gen = X;elseif a >= 1981 && a <= 1999 gen = 'Y';elseif a >= 2000 && a <= 2012 gen = 'Z';else a > 2012 gen = 'K';end
and the feedback says there is error for argument 1965 and 1966.
Please point out or guide me on my mistake.
Best Answer