function ggprime=pderhsnew(t,gg,opt,k,dx,A,n) heat=(k/dx^2)*A*gg; % this one is from class G=reshape(gg,n,n); e=ones(n,1); S=spdiags([e 0*e -e],-1:1,n,n); S(n,1)=-1; S(1,n)=1; ADV=S*G; adv=reshape(ADV,n^2,1); % this one makes it move in both directions (x and y) % (added later) %f=ones(n^2,1); %T=spdiags([f 0*f -f],-1:1,n^2,n^2); %T(1,n^2)=1; %T(n^2,1)=-1; %adv=T*gg; ggprime=heat+10*adv;