MATLAB: Surf, plotting, axis

axisplottingsurf

Hi
Simple question….
I have an output 'P' which is a 10X10 matrix. I start with
for i=1:10
for j=1:10
P(i,j) = %some operation that gives the answer at each i,j


end
end
I use 'surfl' to plot P.
Now I have
for i=1:0.5:10
for j=1:0.5:10
P(i,j) = %some operation that gives the answer at each i,j
end
end
Then, P will still be a 20X20 matrix, but its now plotting on surf, because I think it takes only integers.
So, I used
c1=1;
for i=1:0.5:10
c2=1;
for j=1:0.5:10
P(c1,c2) = %some operation that gives the answer at each i,j
c2=c2+1;
end
c1=c1+1;
end
surf(P)
This gives me a figure for a 20X20 matrix I want, but its mentioned as 1:20 and 1:20 on x & y-axes, while I want it to depict 1:10 and 1:10….
Please advice what I need to change to get that!!!

Best Answer

xv = 1 : 0.5 : 10;
yv = 1 : 0.5 : 10;
for i = 1 : length(xv)
for j = 1 : length(yv)
P(i,j) = %some operation that gives the answer at each xv(i), yv(j)
end
end
surf(xv, yv, P)