# DTMF Tone Generation in MATLAB not sounding right

I'm starting out with some DTMF Tone Generation using Matlab and I wanted to find some theory behind how to generate the various tones for a 4x3 keypad consisting of 0-9, * and #. So far I have the following function:

function y = OutputTone(c)

t = 0:0.1:500;
num = double(c);
%fs = 8000;

if (num == 49) || (num == 50) || (num == 51) % 1, 2, 3
f1 = 697;
if (num == 49)
f2 = 1209;
elseif (num == 50)
f2 = 1336;
elseif (num == 51)
f2 = 1477;
end
elseif (num == 52) || (num == 53) || (num == 54) % 4, 5, 6
f1 = 770;
if (num == 52)
f2 = 1209;
elseif (num == 53)
f2 = 1336;
elseif (num == 54)
f2 = 1477;
end
elseif (num == 55) || (num == 56) || (num == 57) % 7, 8, 9
f1 = 852;
if (num == 55)
f2 = 1209;
elseif (num == 56)
f2 = 1336;
elseif (num == 57)
f2 = 1477;
end
elseif (num == 42) || (num == 48) || (num == 35) % *, 0, #
f1 = 941;
if (num == 42)
f2 = 1209;
elseif (num == 48)
f2 = 1336;
elseif (num == 35)
f2 = 1477;
end
end

y = sin(2*pi*f1*t) + sin(2*pi*f2*t); % DTMF Signal in Time Domain

end


As the code describes above, I take in an input character (0-9,*,#), convert it to ASCII and then select the appropriate DTMF frequency pertaining to the key that is pressed. For example, if 1 is input to the function, then the frequencies f1 = 697Hz and f2 = 1209Hz will be selected and applied to the output sinusoid y.

However, when I play back the sound of y, it doesn't sound anything like the key tones I hear on my smartphone or in this link. What is the correct way to represent y?

You have commented the line that you assign fs. Then the time duration t should be defined with respect to fs.
fs = 8000;