Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com MATLAB CODING PROBLEM..pls help

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 05-13-2013, 12:55 PM PM User | #1 arpitgupte New to the CF scene   Join Date: May 2013 Posts: 2 Thanks: 0 Thanked 0 Times in 0 Posts 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'); F = fread(fid); 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)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'); F1 = fread(fid1); 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 k4 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 i0 & i1 & (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
 05-13-2013, 12:57 PM PM User | #2 arpitgupte New to the CF scene   Join Date: May 2013 Posts: 2 Thanks: 0 Thanked 0 Times in 0 Posts

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 12:54 AM.