Hello readers!
So while working on my Neural Networks homework, I stumbled across an interesting problem when using the surf command in Matlab. Try running the following commands:
Xi = -2 + [0:20]*0.2;
Xj = -2 + [0:20]*0.2;
X = zeros(2,size(Xi,2)*size(Xj,2));
for i = 1:size(Xi,2)
n = (i-1) * size(Xj,2);
for j = 1:size(Xj,2)
X(:,n + j) = [Xi(i); Xj(j)];
end
end
Y = -1 + double((X(1,:).^2 + X(2,:).^2)
surf(Xi,Xj,reshape(Y,size(Xi,2),size(Xj,2)))
Running this on two different machines produces different graphs:
vs
The first image is the correct output. Note how in the second image, the top-right corner of the cylinder is chopped off. Check your Matlab and see what it outputs. Both of these images were done using Matlab 2007a. If you have a version that doesn’t output the correct graphs, a remedy to the problem is to go to “Edit”->”Copy Figure”, it will either rerender the image on the screen, or at worst put the correct image into the copy buffer.
Fekete András
1 comment
Andrew Kun says:
November 6, 2007 at 7:47 am (UTC -4)
This problem did appear on my machine.