Create 3D Plots in MATLAB

MATLAB Illustration

Three-dimensional plots visualize functions of two variables, surfaces, volumes, or point clouds. Key functions: surf, mesh, plot3, scatter3, contour3.

Common 3D Plot Types

  • Surface Plot: surf(X,Y,Z) – colored surface.

 
surf - Surface plot - MATLAB
 
Classic MATLAB surf(peaks) example.

 
peaks - Peaks function - MATLAB

Peaks function surface plot.

  • Mesh Plot: mesh(X,Y,Z) – wireframe grid.

 
Creating 3-D Plots - MATLAB & Simulink Example

Example mesh plot.

  • Line Plot: plot3(x,y,z) – 3D curves (e.g., helix).
  • Scatter: scatter3(x,y,z,s,c) – colored points.
  • With Lighting: surfl(Z) or shading interp; light;.

Basic Steps

  1. Generate Grid: [X,Y] = meshgrid(-3:0.1:3); (for domain).
  2. Compute Z: Z = sin(sqrt(X.^2 + Y.^2)); or Z = peaks;.
  3. Plot: surf(X,Y,Z); or mesh(X,Y,Z);.
  4. Customize:
    • colormap(parula); or jet, hot.
    • shading interp; (smooth).
    • colorbar; (scale).
    • xlabel('X'); ylabel('Y'); zlabel('Z'); title('My 3D Plot');.
    • view(az,el); or rotate interactively.
    • axis tight; grid on;.

Quick Example Code

matlab
 
% Classic peaks surface  [X,Y] = meshgrid(-3:0.1:3);  Z = peaks(X,Y);  figure;  surf(X,Y,Z);  colormap(parula);  shading interp;  colorbar;  title('3D Surface Plot: peaks()');  xlabel('X'); ylabel('Y'); zlabel('Z');
 
 

matlab
 
% Helix line plot  t = 0:pi/50:10*pi;  plot3(sin(t), cos(t), t);  grid on;  title('3D Helix');
 
 

Tips

  • Use figure; hold on; for multiple plots.
  • For better visuals: camlight; material shiny;.
  • Export: saveas(gcf,'plot.png');.

Ideal for data visualization, mathematical functions, and engineering surfaces.

What Our Students Say

★★★★★

“I got full marks on my MATLAB assignment! The solution was perfect and delivered well before the deadline. Highly recommended!”

Aditi Sharma, Mumbai
★★★★☆

“Quick delivery and excellent communication. The team really understood the problem and provided a great solution. Will use again.”

John M., Australia

Latest Blogs

Explore how MATLAB Solutions has helped clients achieve their academic and research goals through practical, tailored assistance.

Battery Management System (BMS) in Electric Vehicles Using MATLAB & Simulink

The rapid adoption of electric vehicles (EVs) has increased the demand for efficient battery management systems (BMS). As the battery is the primary energy source of an EV, ensuring its safety, performance, and longevity is c

A Developer’s Guide to Battery SOC Estimation in MATLAB & Simulink

Imagine you are driving an EV. The dashboard screen shows a comforting 15% State of Charge (SOC)plenty of range to reach the next charging station. Then, suddenly, the powertrain loses power and the car shuts down.  In the BMS world, this is the ultimate nightmare. It’s the result of i