here's what i have:
Fs = 8000;t =0.5;n=[1:ceil(t*Fs)];T1 = sin(2*pi*(697/Fs)*n) + sin(2*pi*(1209/Fs)*n); %T1=key one(1)
T2 = sin(2*pi*(697/Fs)*n) + sin(2*pi*(1336/Fs)*n); %T2=key two(2)
T3 = sin(2*pi*(697/Fs)*n) + sin(2*pi*(1477/Fs)*n); %T3=key three(3)
T4 = sin(2*pi*(770/Fs)*n) + sin(2*pi*(1209/Fs)*n); %T4=key four(4)
T5 = sin(2*pi*(770/Fs)*n) + sin(2*pi*(1336/Fs)*n); %T5=key five(5)
T6 = sin(2*pi*(770/Fs)*n) + sin(2*pi*(1477/Fs)*n); %T6=key six(6)
T7 = sin(2*pi*(852/Fs)*n) + sin(2*pi*(1209/Fs)*n); %T7=key seven(7)
T8 = sin(2*pi*(852/Fs)*n) + sin(2*pi*(1336/Fs)*n); %T8=key eight(8)
T9 = sin(2*pi*(852/Fs)*n) + sin(2*pi*(1477/Fs)*n); %T9=key nine(9)
T0 = sin(2*pi*(941/Fs)*n) + sin(2*pi*(1336/Fs)*n); %T0=key ten(10)
T10 = sin(2*pi*(941/Fs)*n) + sin(2*pi*(1209/Fs)*n); %T10=key asterisk(*)
T11 = sin(2*pi*(941/Fs)*n) + sin(2*pi*(1477/Fs)*n); %T11=key number sign(#)
v=input('NUMBER OF KEYS TO ENTER: ');w=input('ENTER KEY/S: ' ,'s');x=str2num(w); %#ok<ST2NM>
y=length(x);while(1) if (v>y)&&(v<y) disp('ERROR') w=input('ENTER KEY/S: ' ,'s'); elseif v==1;v=y; %when the number of key/s entered is/are one(1)
a=x(1,1); if a==0;subplot(4,3,11);xlabel('KEY0');plot(T0); sound(T0); elseif a==1;subplot(4,3,1);xlabel('KEY1'); plot(T1); sound(T1) elseif a==2; subplot(4,3,2);xlabel('KEY2');plot(T2);sound(T2); elseif a==3;subplot(4,3,3);xlabel('KEY3');plot(T3); sound(T3); elseif a==4;subplot(4,3,4);xlabel('KEY4');plot(T4); sound(T4); elseif a==5;subplot(4,3,5);xlabel('KEY5');plot(T5); sound(T5); elseif a==6;subplot(4,3,6);xlabel('KEY6');plot(T6); sound(T6); elseif a==7;subplot(4,3,7);xlabel('KEY7');plot(T7); sound(T7); elseif a==8;subplot(4,3,8);xlabel('KEY8');plot(T8); sound(T8); elseif a==9;subplot(4,3,9);xlabel('KEY9');plot(T9); sound(T9); elseif a==10;subplot(4,3,10);xlabel('KEY*');plot(T10);sound(T10); elseif a==11;subplot(4,3,12);xlabel('KEY#');plot(T11);sound(T11); end end end
Best Answer