How to plot a surf-plot of semi sphere in matlab using sphere equation
8 views (last 30 days)
Show older comments
JAGADEESH KUMAR M
on 18 Apr 2019
Commented: JAGADEESH KUMAR M
on 19 Apr 2019
Hi, I am trying to plot a semi sphere (with out using sphere command in Matlab) using the sphere equation ((x-a)/r)^2+((y-b)/r)^2+((z-a)/r)^2 = 1; But I am confused hot to choose x, y, z. I tried with the below code but I seem to do some thing wrong somewhere...could any one provide me with a better way to do it
x = 0:1:640;
y = 0:1:480;
[x y] = meshgrid(x,y);
z = -((x-320).^2)/(25)-((y-240).^2)/(25)-1;
z(z<0)=0;
figure();
meshc(z);
My end result should look as shown below

0 Comments
Accepted Answer
darova
on 18 Apr 2019
Take closer look on your equation
Must be:
If you have complex values use:
z1 = real(z); % instead of z(z<0)=0
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!