3D plot in MATLAB of a sphere inside an open pit.

In summary, the aim of the project is to use MATLAB to calculate the volume of a pit to be dug for a football-like object, using the equation X^2+Y^2+(1/4*Z^2) = 25 to determine the shape of the object. The pit must have at least 1 meter clearance from the object in all directions. The project also aims to practice drawing 3D surface plots, numerical integration, and enhancing graphs using MATLAB. The code provided can be used to plot where the pit will be dug and where the object will be placed.
  • #1
mulface
1
0
Ok so I am trying to do this project for uni.

"A working pit is plan to be dug to host a football alike object. The shape of the object is
given by the following equation

X^2+Y^2+(1/4*Z^2) = 25

The object will be put into the place from above, and the wall of the pit must have at least
1 meter clearance from the object in all directions.
Use MATLAB to calculate the volume of the pit, and plot in 3D to show where to dig, and
where the object will be hosted.

Aim:

Practice on MATLAB for the following topics
Draw 3D surface plot.
Numerical integration.
Enhance the graph."


Can anyone help me out, I have this so far...

[x,y,z]=sphere(20);
mesh(x,y,z)
(x^2)+(y^2)+(0.25*z^2);
surf(x,y,z)
axis vis3d on
shading interp
light('Position',[-3 -1 3]);
 
Physics news on Phys.org
  • #2
lighting phonghold on%Calculate the volume of the pitV=4/3*pi*(25^3);disp(V)%Plot in 3D to show where to dig[X,Y,Z]=meshgrid(-1.5:0.2:1.5,-1.5:0.2:1.5,-1.5:0.2:1.5);surf(X,Y,Z)shading interpaxis vis3d onlight('Position',[-3 -1 3]);lighting phong
 

1. How do I plot a 3D sphere in MATLAB?

To plot a 3D sphere in MATLAB, you can use the "sphere" function. This function takes in the center coordinates and radius of the sphere as inputs and produces a 3D plot of the sphere. You can also customize the color, transparency, and other properties of the sphere using additional input parameters.

2. How do I create an open pit in my plot?

To create an open pit in your plot, you can use the "patch" function. This function allows you to create a 3D shape by specifying the coordinates of its vertices. You can use the "rectangle" function to create a rectangular base for your pit and then use the "patch" function to create the sides of the pit. You can also customize the color and other properties of the pit using additional input parameters.

3. How do I combine the sphere and open pit in one plot?

To combine the sphere and open pit in one plot, you can use the "hold" function. This function allows you to plot multiple objects on the same figure. You can use the "sphere" and "patch" functions to plot the sphere and open pit separately, and then use the "hold on" command to keep the current plot and add the next plot to it. Don't forget to use the "hold off" command when you are done plotting to prevent any further changes to the current figure.

4. Can I rotate the 3D plot to view it from different angles?

Yes, you can rotate the 3D plot in MATLAB to view it from different angles. To do this, you can use the "rotate3d" function or enable the "Rotate 3D" tool in the figure toolbar. You can then click and drag the plot to rotate it in different directions. You can also use the "view" function to specify a specific azimuth and elevation angle to view the plot from a specific angle.

5. How do I save the 3D plot as an image or video?

To save the 3D plot as an image, you can use the "saveas" function. This function takes in the figure handle and the desired file format as inputs. To save the plot as a video, you can use the "VideoWriter" class. You will need to specify the frame rate, file format, and other parameters to create the video file. Then, you can use a "for" loop to capture each frame of the plot and write it to the video file using the "writeVideo" function.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
939
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top