function draw_gridmap(s,thrs,rw,cl,spacing)
%subfunction used by raymodel1.m to create visual output of simulated rays
% mat1=(1:60)./60;
% matri=flipud([mat1',zeros(60,1)+1,zeros(60,1)+1]);
% matrib=flipud([zeros(60,1)+1,mat1',zeros(60,1)+1]);

figure;
msp=0;
for m=1:rw,
    
    for n=1:cl,%because cl stores number of compartments for all rays in a column vector 
        
        xcoord=[n-0.5, n+0.5, n+0.5, n-0.5];
        ycoord=[m-0.5 m-0.5 m+0.5 m+0.5]+msp;
        
        cc=s(m,n);
 
        hold on,
        hh=patch(xcoord,ycoord,cc);
        set(hh,'EdgeColor',[0 0 0]);

    end;
    msp=msp+spacing;
end;

axis ij
axis equal
caxis([0 thrs]);
colorbar
%axis off



