Specify 3D axis origins to begin on the centre of surface plot ?

30 views (last 30 days)
Hi,
I have a 3D surface plot of a sphere that i produced using a text file containing x, y, z coordinates.
However, currently the axis appears at the bottom of the sphere.
I was wondering if it is possible to move the origin [0,0,0] of the X, Y, Z axis to cross at the centre of the sphere ?
I have attached a screenshot of the current plot.
I am quite new to MATLAB so any help is appreciated. Thank you!

Answers (2)

Image Analyst
Image Analyst on 4 Jan 2016
Try this:
[x, y, z] = ellipsoid(0,0,0,5.9,3.25,3.25,30);
figure
surf(x, y, z)
axis equal
xl = xlim()
yl = ylim()
zl = zlim()
hold on;
line(2*xl, [0,0], [0,0], 'LineWidth', 3, 'Color', 'k');
line([0,0], 2*yl, [0,0], 'LineWidth', 3, 'Color', 'k');
line([0,0], [0,0], 2*zl, 'LineWidth', 3, 'Color', 'k');
  3 Comments
Meera V
Meera V on 5 Feb 2016
Dear Image Analyst,
I have further queries regarding this current project I am working on. I explained my query in this POST. I would like to identify the furthest and shortest points from the origin in this deformed sphere to calculate the maximum and minimum diameter.
I would like to identify these points in each of the 3 planes, (XY, YZ, XZ), as shown in the images attached.
I came across this previous post where you suggested something similar. I changed some parts of the codes to use the X,Y,Z coordinates of my own sphere and to calculate the distance between the points using the 3D vector. The code I used is attached with this post.
However, the code calculates the distance of the furthest point from each of the points. Would it be possible to calculate the furthest distance of the points from the origin.
I.e:
At the moment, the code outputs the results as:
Point #761 at (-0.0, 0.0) is farthest away from point #1574 at (0.0, -0.0) and is at a distance of 0.010000
  • Can we define the "away from point" as the origin? So the distances could be calculated from that central origin to the other points. This should allow me to identify which point is the furthest and which point is the closest. From this I can calculate the minimum and maximum diameter?
  • The command window outputs the coordinates of the points in 2D
(eg _Point #761 at (-0.0, 0.0)_)
Can it be changed so it displays the 3D coordinates? I changed the code to include the Z axis when calculating the distance but can not change the output display in the command window.
  • In addition to this, can the number of decimal places be increased in the output answer? Since the distances are very small, it require higher number of decimal places. I tried
format long
but it did not increase the decimal places in the results.
Could these problems I am facing currently be resolved?
Thank you.

Sign in to comment.


Walter Roberson
Walter Roberson on 2 Jan 2016
  1 Comment
Meera V
Meera V on 4 Jan 2016
Hi Walter,
Thank you for your answer.
I tried the link on MATLAB, however this seems to be an old 2010 version therefore some of the functions come up as an error. I currently have the R2015b version.
Is there another solution to the problem that i could try?
Thank you

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!