![]() |
| Script ext_ascii.m | |||
|
|||
|
%----------------------------------------------------------
%EXTENDED ASCII CODES M-file:ext_ascii.m %---------------------------------------------------------- %% %cod has size 1x128 and class double cod=(128:255);L1=length(cod) %integers of cod are converted to a string scod %scod has size 1x638 and class char % scod=int2str(cod);L2=length(scod) % %join has size 1x2 and class char join=blanks(2); %scod2 has size 1x640 scod3=[join scod]; L3=length(scod3) % %scod3 is reshaped as the 8x80 array asc1 % %whose elements are taken columnwise from scod3 j1=1;j2=80; for i=1:8 asc1(i,:)=scod3(j1:j2); j1=j1+80;j2=j2+80; end % %asci1 has size 8x80 and class char % %each element of asc1 has size five: so 16x5=80 asc1 whos %---------------------------------------------------------- %% %c_cod has size 1x128 and class char c_cod=char(cod) L4=length(c_cod) %c_cod is reshaped as c_cod640 of size 1x640 %Inserting 4 blanks before each character %each element has size 5 m=1; for k=1:128 c_cod640(m:m+4)=[blanks(4) c_cod(k)]; m=m+5; end c_cod640; L5=length(c_cod640) whos %---------------------------------------------------------- %% %%c_cod640 is reshaped as the array asc2 of 8x80 %whose elements are taken columnwise from c_cod640 n1=1;n2=80; for p=1:8 asc2(p,:)=c_cod640(n1:n2); n1=n1+80; n2=n2+80; 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 %---------------------------------------------------------- |
|||
| Back | |||