MATLAB: Can you vectorize this code

vectorize code

This comes from the Matlab book and I'm having the hardest time understanding it.
Chapter 5, problem 35
Vectorize this code:
n = 3;
x = zeros(n);
y = x;
for i = 1:n
x(:,i) = i;
y(i,:) = i;
end
Please help!

Best Answer

n=3;
x=meshgrid(1:n,1:n);
y=x';