matlab - Undefined function 'lt' for input arguments of type 'cell'. in using cell -


my teacher asked write program huffmam coding in matlab, met problem:

undefined function 'lt' input arguments of type 'cell'.

error in work5455 (line 49)

which line:

if(cell{k+1}(1)<cell{k}(1)&&cell{k}(2)==-1) 

since there no 'lt',how can solve it? teacher busy answer e-mail..... here`s code(not finished),thank much!

fprintf('reading data...') data=imread('c:\users\dell\desktop\2.png'); data=rgb2gray(data); data=uint8(data); fprintf('done!\n')  if~isa(data,'uint8'),     error('input argument must uint8 vector') end f=repmat(0,1,256); len=length(data); j=0:255     i=1:len         if data(i)==j;             f(j)=f(j)+1;         end     end end  f=double(f./len);  simbols=find(f~=0); f=f(simbols); [f,sortindex]=sort(f) simbols=simbols(sortindex)  len=length(simbols); codeword=cell(1,len); huffnode=cell(1,2*len); i=1:len     cell{i}={f(i),-1,-1,-1}; end i=len+1:2*len-1     cell{i}={-1,-1,-1,-1}; end  m=len %for i=1:len j=1:len+i-1     m=m-1;     k=1:m         if(cell{k+1}(1)<cell{k}(1)&&cell{k}(2)==-1)             cell{2*len}=cell{k+1};             cell{k+1}=cell{k};             cell{k}=cell{2*len};         end     end end 

the output of cell{k+1}(1) 1x1 cell. since cannot compare cells other cells, have make datatype conversion using cell2mat number before. using

if(cell2mat(cell{k+1}(1))<cell2mat(cell{k}(1))&&cell2mat(cell{k}(2))==-1) 

should solve problem.
since cell built-in function in matlab highly recommend renaming variable. @andrasdeak stated in comments might problems later on otherwise. in general, should never use built-in function-names variable- or function-names. please note i , j represent imaginary unit in matlab , should not used iteration variables either.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -