You might try replacing the second line with:
f=['x+y+' num2str(k)];
I could not test it as I don't have the PDE toolbox. Hope this helps.
A.
PS: If you have to solve for a lot of k values, there are ways to solve this pde in one shot for all values of k in a given interval. You would get as result a function of three variables: u(x,y,k) (who said k is a parameter and not a variable). The good point is that the memory cost and computational time would still scale like the 2D Poisson, you never solve/store things on a 3D mesh (with k being the third dimension). If you're interested in those emerging methods, its called: Proper Generalized Decomposition (PGD), you might find some recent papers on these.
Adrien
2010-07-29 12:17:46