Three-dimensional plots generally displays a surface defined by a function in two variables, z = f(x,y) .
To evaluate z, first make a set of (x,y) points for domain of the function using meshgrid.
[X,Y] = meshgrid(-2:.2:2);
Z = X .* exp(-X.^2 - Y.^2);
Then, it will create a surface plot.
Both the surf function and mesh shows surfaces in three dimensions. surf shows both the connecting lines and the faces of the surface in color. mesh produces wireframe surfaces that color only those lines connecting the defining points.
There are various three dimensional plots in MATLAB
The mesh function makes a wireframe mesh. By default, the color of the mesh is related to the surface height.
z = peaks(25);
The surf function is used to make a 3-D surface plot.
colormap(jet) % change color map
Surface Plot (with Shading)
The surfl function makes a surface plot with colormap-based lighting. For smooth color transitions, use a colormap with linear intensity variation such as pink.
colormap(pink) % change color map
shading interp % interpolate colors across lines and faces
The contour function is used for creation of a plot with contour lines of constant value.
colormap default % change color map
The quiver function helps to plot 2-D vectors as arrows.
x = -2:.2:2;
y = -1:.2:1;
[xx,yy] = meshgrid(x,y);
zz = xx.*exp(-xx.^2-yy.^2);
[px,py] = gradient(zz,.2,.2);
xlim([-2.5 2.5]) % set limits of x axis
Slices through 3-D Volumes
The slice function helps to displays data at planes that slice through volumetric data.
x = -2:.2:2;
y = -2:.25:2;
z = -2:.16:2;
[x,y,z] = meshgrid(x,y,z);
v = x.*exp(-x.^2-y.^2-z.^2);
xslice = [-1.2,.8,2]; % location of y-z planes
yslice = 2; % location of x-z plane
zslice = [-2,0]; % location of x-y planes
- High-Quality MATLAB assignment help with Powerpoint presentations as complimentary
- Timely delivery of assignments with no unexpected delay from our MATLAB assignment help experts
- With MATLAB assignment help, you can get 24*7 assistance and direct interaction with our representatives live
- The coding assignments are written from scratch to eliminate chances of plagiarism by our MATLAB assignment help experts
- Safe and easy payment options with Paypal at MATLAB assignment help services.