## MATLAB CODING PROBLEM..pls help

CAN ANY1 PLS HELP ME WITH THIS CODE..
ITS NOT COMPRESSING THE INPUT FILE PROPERLY..
I'VE USED HUFFMAN CODING TECHNIQUE HERE..ALONG WITH ENCRYPTION TECHNIQUE OF QPSK ND DPSK..

STEPS:CREATE 4 BLANK FILES, AND CREATE INPUT FILE WITH SOME CONTENT IN IT..
RUN THE CODE
ENTER THE FILENAME:inputfile.txt

ENTER THE COMPRESSED DESTINATION:compress.txt

ENTER GENERATOR POLYNOMIAL:[1 0 0 1 0 1]

ENTER THE ENCRYPTED DESTINATION:encrypt.txt

ENTER THE FILENAME:encrypt.txt

ENTER THE DECRYPTED DESTINATION:decrypt.txt

ENTER THE FILENAME:table.m

ENTER THE DECRYPTED FILENAME:decrypt.txt

ENTER THE DECODED DESTINATION:decoded.txt

IF ANY1 DEBUGS IT..IT'LL BE LOTT OF HELP FOR ME..
THANK YOU..

clc;
clear all;
k=input('enter the filename :','s');
[fid,message] = fopen(k,'r');
img = char(F');
mx=255;
[x y z]=size(img);
h(1:mx)=0;
for i=1:y
iy=img(i);
val=double(iy);
h(val)=h(val)+1;
end
p(1:mx)=0;
for val=1:mx
p(val)=h(val)/y;
end
s(1:mx)=p(1:mx);
st(1:mx)=0;
for i=1:mx
for j=1:mx
if p(j)<p(i)
t=p(j);
p(j)=p(i);
p(i)=t;
end
end
end
q(1:mx)=0;
k=1;
for i=1:mx
for j=1:mx
if p(i)==s(j) & p(i)~=0 & s(j)~=0
q(k)=j;
k=k+1;
i=i+1;
s(j)=1;
j=1;
end
end
end
k=k-1;
disp(q(1:k));
disp(p(1:k));
c(1:k)=p(1:k);
m=2*k;
lst(1:m)=0;
j=1;
for i=1:2:m-1
lst(i)=p(j);
j=j+1;
end
j=1;
for i=2:2:m
lst(i)=q(j);
j=j+1;
end
disp(lst);
lst=fliplr(lst);
disp(lst);
l=k;
for i=1:k
c=sort(c,'descend');
if i~=1
c(l)=c(l)+c(l-1);
c=sort(c,'descend');
c(l)=0;
l=l-1;
end
for j=1:k
a(i,j)=c(j);
end
end
disp(a);
o=3;
for i=1:k
for j=1:k
b(i,k)={0};
end
end
o=3;
u=3;
b(k-1,1)={1};
b(k-1,2)={0};
j=u-2;
disp(b);
for n=k-2:-1:1
for i=o:-1:1
if i~=1
if o<k+1 & a(n+1,i-1)==(a(n,o)+a(n,o-1))
b(n,o)=strcat(b(n+1,i-1),{0});
b(n,o-1)=strcat(b(n+1,i-1),{1});
o=o+1;
else
if j>0 & a(n+1,i-1)==a(n,j)
b(n,j)=strcat(b(n+1,i-1));
j=j-1;
end
end
end
end
u=u+1;
j=u-2;
end
r(1:y)={0};
disp(b);

for i=1:y
for j=1:k
if img(i)== q(j)
r(i)= b(1,j);
end
end
end

r=cell2mat(r);

idd=input('enter the compressed destination','s');
idd=fopen(idd,'w+');
fprintf(idd,'%d',r);
fclose(idd);

tab='table.m';
tb=fopen(tab,'w+');
i=1;
while i<=k

fprintf(tb,'''%c''',q(i));
fprintf(tb,'%d',cell2mat(b(1,i)));
% fprintf(tb,'\t');
i=i+1;
end
fclose(tb);
disp(r);
[x y]=size(r);
len=y;
g=input('enter gen polynomial');
[x y]=size(g);
disp(g);
leng=y;
for i=len+1:len+leng-1
r(i)=0;
end
nc=r;
disp(r);
q1(1:len)=0;
i=1;
while i<=len
if r(i)==1
q1(i)=1;
for j=1:leng
if i<=len+leng-1
r(i)= xor(r(i),g(j));
i=i+1;
end
end
i=i-leng-1;
end
i=i+1;
end
nc=xor(nc,r);
disp(nc);
disp(q1);

i=len+leng-1;
while i>=leng

for j=leng:-1:1
if i>0
nc(i)= xor(nc(i),g(j));
i=i-1;
end
end
end
disp(nc);
nc1=nc;
j=1;
for i=2:2:len+leng-1
nc1(j)=nc(i);
j=j+1;
end

for i=1:2:len+leng-1
nc1(j)=nc(i);
j=j+1;
end
disp(nc1);
[x y]=size(nc1);
pp1=nc1;
rem=mod(y,4);
app=4-rem
for i=1:app
if nc1(y)==0
nc1(y+i)=1;
else
nc1(y+i)=0;
end
end
g1=[1 0 0 0 1 1 1;
0 1 0 0 1 1 0;
0 0 1 0 1 0 1;
0 0 0 1 0 1 1];
[n m]=size(nc1);
i=1;
for k=1:4:m
l=i+5;
for i=i:i+6
sum=0;

for j=k:k+3
sum=xor(sum,(nc1(1,j)*g1(j-k+1,i+6-l)));

end

nc2(1,i)=sum;

end
i=i+1;
end

[n m]=size(nc2);

for i=1:7:m
low=0;
high=7;
x=low+(high-low)*rand();
x=ceil(x);
b=1;
for j=i:i+6
if b==x
nc3(j)=1-nc2(j);
else
nc3(j)=nc2(j);
end
b=b+1;
end
end
j=1;
[x y]=size(nc3);
for i=1:8:y

if (y-i)>=8
kc(j)=bi2de(nc3(i:i+7),'left-msb');
j=j+1;
else
kc(j)=bi2de(nc3(i:y),'left-msb');
kc(j+1)=y-i+1;
end
end
[x y]=size(kc);

ec=input('enter the encrypted destination','s');
ec=fopen(ec,'w+');
for i=1:y
fprintf(ec,'%c',char(kc(i)));
end
fclose(ec);
k1=input('enter the filename :','s');
[fid1,message] = fopen(k1,'r');
img1 = F1';
[x y]=size(img1);
j=1;
for i=1:y-1
if i==(y-1)
z=img1(y);
nc1(j:j+z-1)=de2bi(img1(i),z,'left-msb');

else
nc1(j:j+7)=de2bi(img1(i),8,'left-msb');
j=j+8;
end
end

nc1=logical(nc1);

[n m]=size(nc1);
h=[1 1 1 0 1 0 0;
1 1 0 1 0 1 0;
1 0 1 1 0 0 1;];
h=h';
v=1;
for k=1:7:m
for i=1:3
sum=0;
for j=k:k+6
sum=xor(sum,(nc1(1,j)*h(j-k+1,i)));
end
c(v,i)=sum;
end
v=v+1;
end
c1=[0 0 0];
c1=logical(c1);
h=logical(h);
[n m]=size(c);
for k=1:n
tf=isequal(c(k,1:3),c1);

while tf~=1
for i=1:7
tf1=isequal(c(k,1:3),h(i,1:3));
if tf1==1
e(i)=1;
else
e(i)=0;
end
end
tf=1;
end
nc4((7*k)-67*k))=xor(e,nc1((7*k)-67*k)));
end

[n m]=size(nc4);
j=1;
f=1;
k=1;
while k<m
nc5(j)=nc4(k);
f=f+1;
j=j+1;
k=k+1;
if f>4
k=k+3;
f=1;
end
end
[x y]=size(nc5);
k=1;
i=y;
while nc5(i)==nc5(i-1)
k=k+1;
i=i-1;
end
nc6(1:y-k)=nc5(1:y-k);
j=1;
for i=2:2:len+leng-1

nc(i)=nc6(j);
j=j+1;

end

for i=1:2:len+leng-1

nc(i)=nc6(j);
j=j+1;

end
i=len+leng-1;
while i>=leng

for j=leng:-1:1
if i>0
nc(i)= xor(nc(i),g(j));
i=i-1;
end
end
end
disp(nc);

dc=input('enter the decrypted destination','s');
dc=fopen(dc,'w+');
fprintf(dc,'%d',nc);
fclose(dc);
k2=input('enter the filename :','s');
[fid2,message] = fopen(k2,'r');
hf=fscanf(fid2,'%c',inf);
hf=num2cell(hf);

[x y]=size(hf);
hf{y+1}=' ';
y=y+1;
j=0;
k=0;
for i=1:y
if i<y & (hf{i+1}=='''' & hf{i-1}=='''')
j=j+1;
hf1(j)=hf(i);
j=j+1;
k=0;
elseif (hf{i}=='1' | hf{i}=='0')& k>0 & i<y
if i>1 & (hf{i+1}~='''' | hf{i-1}~='''')
hf1(j)=strcat(hf1(j),hf(i));
end
elseif (hf{i}=='1' | hf{i}=='0')& k==0

hf1(j)=hf(i);
k=k+1;

end

end
k3=input('enter the decrypted filename :','s');
[fid3,message] = fopen(k3,'r');
org=fscanf(fid3,'%c',inf);
org=num2cell(org);
[x y]=size(org);
l1=y-leng+1;
[x y]=size(hf1);
l2=y;
dc1=input('enter the decoded destination','s');
dc1=fopen(dc1,'w+');

for i=1:l1
[x y]=size(org{i});
t1=y;
for j=2:2:l2

[x y]=size(hf1{j});
t2=y;
if t1==t2 & org{i}==hf1{j}
fprintf(dc1,'%c',cell2mat(hf1(j-1)));
break;
end

if j==l2
org(i+1)=strcat(org(i),org(i+1));

end
end
end