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.

MCP-Enabled Robotics Control Systems with MATLAB

In today\\\'s rapidly advancing era of automation, robotics control systems are evolving to meet the demand for smarter, faster, and more reliable performance. Among the many innovations driving this transformation is the use of MCP (Model-based Control Paradigms)

LLM-Driven Financial Forecasting Models in MATLAB

The financial sector is witnessing a technological revolution with the rise of Large Language Models (LLMs). Traditionally used for text analysis, LLMs are now being integrated with powerful platforms like MATLAB to develop financial forecasting models