DTMF encoder

fs = 8000; % sample frequency
tmax = 0.1; % tone duration

t = linspace(0,tmax,tmax*fs+1);
yn = 0.5*tmax*fs;
fL = [697 770 852 941];
fH = [1209 1336 1477 1633];
% pick one low frequency and one high frequency
omega1 = 2*pi*fL(1);
omega2 = 2*pi*fH(2);
y = sin(omega1*t)+sin(omega2*t);
idx = find(t<=0.02);
plot(t(idx)*1e3,y(idx),'k','LineWidth',2);
grid;
xlabel('time (msec)');
ylabel('signal');
sound(y,fs);