%COMP 256 Assignment 1
%Adrian Ilie

function r=integrate(p,q)

imsize=size(p);
r=zeros(imsize);

p(find(isnan(p)))=0;
q(find(isnan(q)))=0;

for i=2:imsize(1)
    r(i,1)=r(i-1,1)+q(i,1);
end

for i=2:imsize(1)
    for j=2:imsize(2)
        r(i,j)=r(i,j-1)+p(i,j);
    end
end