i want optimize some loop code such as below . my code is working with large matrix and must be optimized . please help me .
Example one: Expecting Boolean results:
m=zeros(100,100);
r=rand(100,100);
for i=1:100
for j=1:100
if(r(i,j)<0.3 || r(i,j)>0.7)
m(i,j)=1;
else
m(i,j)=0;
end
end
end
Example two: Expecting NON-Boolean results
m=zeros(100,100);
r=rand(100,100);
for i=1:100
for j=1:100
if(r(i,j)<0.3 || r(i,j)>0.7)
m(i,j)=0.035;
else
m(i,j)=0;
end
end
end