"David Berrow" <berrow@engr.mun.ca> wrote in message
news:fod096$aid$1@fred.mathworks.com...
>I know MATLAB is supposed to store new values of an object
> defined by X,Y,Z matrices when the rotate function is used
> on it. I have the following code but my X,Y,Z values do
> not change. I am not sure why!
>
> ber=surf(X,Y,Z); % berg surface
> k=[0 0 1]; % vector in zdirection
> yi=[0 1 0]; % vector in ydirection
> alpha=45
> gamma=53
> rotate(ber,k,alpha); %rotate berg alpha degrees about zaxis
> rotate(ber,yi,gamma); %rotate berg gamma degrees about yaxis
The ROTATE function rotates the object whose handle you provide to it. That
modifies the properties _of that object_, not _the variables that were used
to create that object_. After all, those variables may no longer exist, or
you may have used an expression that is not a variable to create the object.
In order to see the modified data, you need to GET it from the object.
[x, y] = meshgrid(1:0.1:1, 1:0.1:1);
h = surf(x, y, x+y);
pause % so you can see the original surface
rotate(h, [0 0 1], pi/4)
newx = get(h, 'XData');
newy = get(h, 'YData');
isequal(x, newx) % should return false

Steve Lord
slord@mathworks.com
