Look up the char function in Matlab. Use it along with the fact that the hexadec
ID: 1766025 • Letter: L
Question
Look up the char function in Matlab. Use it along with the fact that the hexadecimal code for A is 65 and a is 97, (check an ASCII Table if necessary). Note that the hex code increases by one for each subsequent character, (you might need to review counting in hexadecimal). Create 2 strings one for the upper case alphabet and one for the lower case alphabet. Note: Do not type out the upper and lower case alphabet in your script file, no credit will be earned! Combine the strings into a matrix. Then use a loop and any other helpful programming techniques to print out the upper and lower case alphabets vertically as shown below. Hint: You may find it useful to reference individual characters of the string matrix portions of the string matrix. Uppercase Lowercase A a B b etc.
Explanation / Answer
clc
clear all
close all
temp=65;
temp1=97;
for i=1:26
capalph{i}=char(temp);
smallalph{i}=char(temp1);
temp=temp+1;
temp1=temp1+1;
end
alphmat=[capalph' smallalph'];
[m,n]=size(alphmat);
fprintf('The alphabets obtained from ASCII code are ')
for j=1:m
for k=1:n
a=alphmat(j,k);
fprintf('%s ',alphmat{j,k})
end
fprintf(' ')
end
Output:
The alphabets obtained from ASCII code are
A a
B b
C c
D d
E e
F f
G g
H h
I i
J j
K k
L l
M m
N n
O o
P p
Q q
R r
S s
T t
U u
V v
W w
X x
Y y
Z z
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.