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.

MATLAB Autonomous Vehicle Path Planning Project for Students: Step-by-Step with Code

One of the most fascinating and sought-after projects for engineering students is autonomous vehicles. One of the main challenges in the development of self-driving cars is path planning, which is the process of determining a safe, collision-free route from start to o

Battery Management System (BMS) in Electric Vehicles Using MATLAB & Simulink: A Comprehensive Guide

The Battery Management System (BMS) serves as the intelligent brain of an electric vehicle (EV) battery pack. It ensures safety, maximizes performance, extends battery life, and optimizes energy usage in real-world driving conditions. As EVs become mainst