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.

Unlocking Generative AI in MATLAB: Practical Guide to MATLAB Copilot and Beyond

Generative AI in MATLAB is transforming how engineers, scientists, and researchers approach coding, prototyping, and problem-solving. No longer do you need to switch between tools or struggle with syntax MATLAB Copilot, MathWorks' officia

AI Sovereignty & Governance: What Does Responsible AI Mean for Engineers?

Introduction Not long ago, AI governance was a topic reserved for policy rooms and ethics co