Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change 3D view in matlab

Tags:

matlab

I would like to change the view of a 3D plot in matlab such that the y-axis points upward and the z-axis points to left. For example, consider the following plot:

enter image description here

Here the x-axis points forward, the y-axis points to the right and the z-axis points upward.

I would like to have the y-axis points upward and the z-axis points to the left instead. I tried to rotate the plot (using the figure window toolbar rotate button) but I could not get it to work. (It should just be a simple 90 degrees rotation about the x-axis)

Code to generate the plot:

  membrane
  view(100,50)
  xlabel('x-axis');
  ylabel('y-axis');
  zlabel('z-axis');
  grid on
like image 233
Håkon Hægland Avatar asked Jan 28 '14 11:01

Håkon Hægland


People also ask

How do I change the view in MATLAB?

Change the View Using a Vector Change the view by specifying v as the x- y- and z-coordinates of a vector, and return the new azimuth and elevation angles. The new angles are based on a unit vector pointing in the same direction as v .

How do you rotate 3-D in MATLAB?

r = rotate3d( fig ) creates a rotate3d object for the specified figure.

How do you do 3-D in MATLAB?

plot3( X , Y , Z ) plots coordinates in 3-D space. To plot a set of coordinates connected by line segments, specify X , Y , and Z as vectors of the same length. To plot multiple sets of coordinates on the same set of axes, specify at least one of X , Y , or Z as a matrix and the others as vectors.

How do I change the camera position in MATLAB?

You can change the orientation of the scene by specifying the direction defined as up. By default, MATLAB defines up as the y-axis in 2-D views (the CameraUpVector is [0 1 0] ) and the z-axis for 3-D views (the CameraUpVector is [0 0 1] ). However, you can specify up as any arbitrary direction.


1 Answers

Try using view. I don't have MATLAB available so I can't test it, but I think it can do what you want.

Example from the documentation:

Set the view along the y-axis, with the x-axis extending horizontally and the z-axis extending vertically in the figure.

view([0 0]);

EDIT:

Try using three inputs to the view function. I can't experiment myself, but you should be able to do it if you choose the right values here.

From documentation:

view([x,y,z]) sets the view direction to the Cartesian coordinates x, y, and z. The magnitude of (x,y,z) is ignored.

EDIT 2:

Check out camroll. I think camroll(90) (possibly in combination with view) will work.

From documentation:

camroll(dtheta) rotates the camera around the camera viewing axis by the amounts specified in dtheta (in degrees). The viewing axis is the line passing through the camera position and the camera target.

like image 106
Stewie Griffin Avatar answered Sep 17 '22 18:09

Stewie Griffin