hai matlab experts , this is a line of code in my matlab program
reqBinData = dec2bin(newImg2);
when i am run this snippet in matlab 7.6.0 R2008a , it does not give any error.
but when i run it in matlab 7.8.0.347 R2009a it gives the following error:
??? Operands to the  and && operators must be convertible to logical scalar values.
Error in ==> dec2bin at 31
if any(d < 0)  any(~isfinite(d))
reqBinData = dec2bin(newImg2);
Error in ==> sampic2abb at 122
what is the reason; newImg2 is a double variable; even i type casted that in to uint8 data type; but still i cannot fiix this problem.
thanks in advance.

i have attached the entire code for the reference:

clear;
clc;
a = imread('file.bmp'); %Reading Input File
% stochastic resonance begins here
% D=size(a);
% M=D(1,1);
% N=D(1,2);
% a=double(a);
%
% %sigma=1;
% a=quant(a,4);
% a=a+randn(M,N);
% a=uint8(a);
% stochastic resonace ends here
b = bitand(a,240); %Extracting First 4 Bits from the MSB
% The following code will push 7,6,5,4th bit to right side; since i am not okay with rotation operatoin i did like this
for i = 1:size(a,1)
for j = 1:size(a,2)
if(b(i,j)== 240)
b1(i,j)=15;
elseif(b(i,j)== 224)
b1(i,j)=14;
elseif(b(i,j)== 208)
b1(i,j)=13;
elseif(b(i,j)== 192)
b1(i,j)=12;
elseif(b(i,j)== 176)
b1(i,j)=11;
elseif(b(i,j)== 160)
b1(i,j)=10;
elseif(b(i,j)== 144)
b1(i,j)=9;
elseif(b(i,j)== 128)
b1(i,j)=8;
elseif(b(i,j)== 112)
b1(i,j)=7;
elseif(b(i,j)== 96)
b1(i,j)=6;
elseif(b(i,j)== 80)
b1(i,j)=5;
elseif(b(i,j)== 64)
b1(i,j)=4;
elseif(b(i,j)== 48)
b1(i,j)=3;
elseif(b(i,j)== 32)
b1(i,j)=2;
elseif(b(i,j)== 16)
b1(i,j)=1;
elseif(b(i,j)== 0)
b1(i,j)=0;
end
end
end
% This is gray code coversion for 7,6,5,4th bit; since i am not okay with gray code operation i did like thi
% i am aware that both these operatoins inbuilt functions are available, but still i used
% logic for that
for i = 1:size(a,1)
for j = 1:size(a,2)
if(b1(i,j)== 15)
b2(i,j)=8;
elseif(b1(i,j)== 14)
b2(i,j)=9;
elseif(b1(i,j)== 13)
b2(i,j)=11;
elseif(b1(i,j)== 12)
b2(i,j)=10;
elseif(b1(i,j)== 11)
b2(i,j)=14;
elseif(b1(i,j)== 10)
b2(i,j)=15;
elseif(b1(i,j)== 9)
b2(i,j)=13;
elseif(b1(i,j)== 8)
b2(i,j)=12;
elseif(b1(i,j)== 7)
b2(i,j)=4;
elseif(b1(i,j)== 6)
b2(i,j)=5;
elseif(b1(i,j)== 5)
b2(i,j)=7;
elseif(b1(i,j)== 4)
b2(i,j)=6;
elseif(b1(i,j)== 3)
b2(i,j)=2;
elseif(b1(i,j)== 2)
b2(i,j)=3;
elseif(b1(i,j)== 1)
b2(i,j)=1;
elseif(b1(i,j)== 0)
b2(i,j)=0;
end
end
end
c = bitand(a,15); %Extracting Last 4 Bits from the LSB
n = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
cntval = n;
disp('Size of the Image: ')
disp(size(a));
for i = 1:size(a,1)
for j = 1:size(a,2)
n(c(i,j)+1) = n(c(i,j)+1) + 1;
end
end
maxn = max(n);
disp('0\t1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11\t12\t13\t14\15');
disp(n);
disp('Total Value of the Pixels from 0 to 7');
disp(sum(n(:)));
for i = 1:16
if n(i) ~= maxn
n(i) = 0;
end
end
indn = find(n);
indn = indn  1; %Index Stores the most frequently occuring value in the last 4 bits
disp('Maximum Value Index');
disp(indn);
newImg2 = b2;
reqBinData = dec2bin(newImg2);
% reqBinData1 = dec2bin(b);
reqBinData = reqBinData';
singlArr = [reqBinData(4,:),reqBinData(3,:),reqBinData(2,:),reqBinData(1,:)];
dlmwrite('1.txt',singlArr, 'delimiter',' ','newline','pc');
reqMetrics = [size(a), indn]; %Metrics Required to Decode the file
disp(reqMetrics);
dlmwrite('metrics.txt',reqMetrics, 'delimiter',' ','newline','pc');
