MATLAB: When i execute function the matlab is being struck; is there any wrong with this simple code??

codeerrorfor loop

In the following arr is a array(1-d) in which each row has three columns of
x-co-ordinate , y-co-ordinate and intensity values ;
m*n is the required size of output image ie fgt here.
In the code initially i have simply assigned all values to 65539(which is not in range of uint16)
function [fgt]= reconstruct ( arr,m,n)
fgt=zeros(m,n);
fgt(:,:)=65539; %
l=size(arr,2)-2;
for i=1:l
fgt(arr(i),arr(i+1))=arr(i+2);
i=i+3;
end
for i=1:m
for j=1:n
if(fgt(i,j)==65539)
fgt(i,j)=0;
end
end
end

Best Answer

If arr is a real array, then there will be a problem with fgt(arr(i),arr(i+1))