Script ascii_codes.m
Download Script ascii_codes.m
%----------------------------------------------------------
%TABLE OF THE ASCII CODES M-file:ascii_codes.m
%----------------------------------------------------------
%%
%cod has size 1x96 and class double
cod=(32:127); %L1=length(cod)
%integers of cod are converted to a string s_cod
%s_cod has size 1x477 and class char
%
s_cod=int2str(cod); %L2=length(scod)
%
%join has size 1x3 and class char
join=blanks(3);
%scod3 has size 1x480
s_cod3=[join s_cod]; %L3=length(scod3)
%scod3 is reshaped as the 8x60 array asc1
%whose elements are taken columnwise from scod3
j1=1;j2=60;
for i=1:8
asc1(i,:)=s_cod3(j1:j2);
j1=j1+60;j2=j2+60;
end
%asci1 has size 8x60 and class char
%each element of asc1 has size five: so 5x12=60
asc1
%whos
%----------------------------------------------------------
%%
%c_cod has size 1x96 and class char
c_cod=char(cod); %L4=length(car)
%c_cod is reshaped as c_cod480 of size 1x480
%Inserting 4 blanks before each character
%each element has size 5
m=1;
for k=1:96
c_cod480(m:m+4)=[blanks(4) c_cod(k)];
m=m+5;
end
c_cod480; %L5=length(c_cod480)
%whos
%----------------------------------------------------------
%%
%%c_cod480 is reshaped as the array asc2 of 8x60
%whose elements are taken columnwise from c_cod480
n1=1;n2=60;
for p=1:8
asc2(p,:)=c_cod480(n1:n2);
n1=n1+60;
n2=n2+60;
end
asc2
%whos
%----------------------------------------------------------
%%
%asc1 and asc2 are merged rowwise
%forming tab_ascii of size 16x60 and class char
%the first row of asc1 becomes the first row of tab_ascii
%the first row of asc2 becomes the second row of tab_ascii
%and so on
for q=1:8
tab_ascii(2*q-1,:)=asc1(q,:);
tab_ascii(2*q,:)=asc2(q,:);
end
tab_ascii
whos cod s_cod s_cod3 c_cod c_cod480 asc1 asc2 tab_ascii
%----------------------------------------------------------
Back