# Each number on telephone keypads, except 0 and 1, corresponds to a set of uppercase letters as shown in this list: 2 ABC, 3 DEF, 4 GHI, 5 JKL, 6 MNO, 7 PQRS, 8 TUV, 9 WXYZ Hence, a phone-number specification can include uppercase letters and digits.

2 views (last 30 days)
Emma Sellers on 3 Jan 2019
Answered: RAMAKANT SHAKYA on 7 Feb 2019
I can not quite figure out why my code does not perform. I keep getting syntax errors that dont make sense to me. Such as "parse errors"
Emma Sellers on 3 Jan 2019
function [telephone] = dial(up)
characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
numbers = '012345678922233344455566677778889999';
[boolean,coords] = ismember(up,characters);
telephone = sscanf(numbers(coords), '%lu');
for i = 1 : sizeof(up)
if boolean(i) = 0
telephone = [];
end
end
end

Neil Sheridan on 3 Jan 2019
Firstly sizeof isn't a function (on my MATLAB setup) so I changed to size. Also, use == to check equality of numbers.
for i = 1 : size(up)
if boolean(i) == 0
telephone = [];
end
end
Emma Sellers on 4 Jan 2019
Figured it out.. All i had to do was put uint64(0).

Neil Sheridan on 4 Jan 2019
When a character is not found in characters() then coords(i) will be 0. numbers(0) will return an error because there is no zeroth element.

RAMAKANT SHAKYA on 7 Feb 2019
function s2=dial(n)
p=[n];
s1='';
tx = ismember(p, ['A':'Z','0':'9']);%only digits and capital letters
tx1=sum(tx);
if length(p)<=16&& p(1,1)~='0'&& tx1==length(p) %finding letters
for c=1:length(p)
if p(c)=='A' || p(c)=='B' || p(c)=='C'
s='2';
elseif p(c)=='D' || p(c)=='E' || p(c)=='F'
s='3';
elseif p(c)=='G' || p(c)=='H' || p(c)=='I'
s='4';
elseif p(c)=='J' || p(c)=='K' || p(c)=='L'
s='5';
elseif p(c)=='M' || p(c)=='N' || p(c)=='O'
s='6';
elseif p(c)=='P' || p(c)=='Q' || p(c)=='R' || p(c)=='S'
s='7';
elseif p(c)=='T' || p(c)=='U' || p(c)=='V'
s='8';
elseif p(c)=='W' || p(c)=='X' || p(c)=='Y' || p(c)=='Z'
s='9';
else
for r=0:9 %finding digit if present
t=num2str(r);
if p(c)==t
s=t;
end
end
end
s2=str2num(s1); %change into number
s2=uint64(s2); %changing class
end
else
s2=uint64(0);
end
end