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.
10 次查看(过去 30 天)
显示 更早的评论
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"
3 个评论
Star Strider
2019-1-3
Please copy and paste your code from your Editor window to a Comment here.
Pictures of code are like pictures of food — enticing but not nourishing.
回答(3 个)
Neil Sheridan
2019-1-3
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
Neil Sheridan
2019-1-4
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.
0 个评论
RAMAKANT SHAKYA
2019-2-7
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
s1=strcat(s1,s); %adding string
s2=str2num(s1); %change into number
s2=uint64(s2); %changing class
end
else
s2=uint64(0);
end
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!