Feed on Posts or Comments

Matlab & Software & User interface András Fekete on 31 Oct 2007 12:49 pm

Matlab peculiarities

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:
Good matlab image vs Bad Matlab image

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

One Response to “Matlab peculiarities”

  1. on 06 Nov 2007 at 7:47 am 1.Andrew Kun said …

    This problem did appear on my machine.

Subscribe to the comments through RSS Feed

Leave a Reply