MATLAB: Day of the week in a month

function

Write a function dayName that consumes a parameter, day, containing the numerical value of a day in April 2012. Your function should return the name of that day as a string. For example: dayName(24) should return 'Tuesday'. Test your program on two cases: dayName(18) and dayName(27).
This is what the code that i ran on matlab it gave me an error i dont understand why
function results = dayName(x)
if (x= 2 9 16 23 30)
results = 'Monday' ;
elseif (x= 3 10 17 24)
results = 'Tuesday' ;
elseif (x= 4 11 18 25)
results = 'Wednesday' ;
elseif (x= 5 12 19 26)
results = 'Thursday' ;
elseif (x= 6 13 20 27)
results = 'Friday' ;
elseif (x=7 14 21 28)
results = 'Saturday');
elseif (x= 1 8 15 22 29)
results = 'Sunday');
end
else
end

Best Answer

You want to use
if any(x==[2 9 16 23 30])
and so on. Also at the bottom, you seem to have an extra else hanging around.