MATLAB provides specialized functions for visualizing three-dimensional data including 3D line plots, shaded surface maps, wireframe meshes, and volumetric scatter graphs. These functions help engineers and researchers analyze multi-variable datasets, spatial trajectories, and mathematical surfaces.
Plot spatial curves and trajectories along three coordinates (X, Y, Z) using the plot3() function:
% 3D Helix Trajectory t = 0:pi/50:10*pi;
st = sin(t);
ct = cos(t);
figure;
plot3(st, ct, t, 'LineWidth', 2, 'Color', 'r');
grid on;
xlabel('X = sin(t)');
ylabel('Y = cos(t)');
zlabel('Z = t (Time / Height)');
title('3D Helix Trajectory Plot');
view(45, 30);
% Set azimuth and elevationVisualize bivariate mathematical functions (Z = f(X,Y)) over a 2D domain grid created with meshgrid():
% Create 2D Grid Coordinates [X, Y] = meshgrid(-2:0.1:2, -2:0.1:2);
Z = X .* exp(-X.^2 - Y.^2);
% 1. Shaded 3D Surface Plot
figure;
surf(X, Y, Z);
colormap(jet);
colorbar;
shading interp;
% Smooth color transitions
title('3D Surface Plot using surf()');
xlabel('X-Axis');
ylabel('Y-Axis');
zlabel('Z-Axis');
% 2. 3D Wireframe Mesh Plot
figure;
mesh(X, Y, Z);
colorbar;
title('3D Wireframe Mesh using mesh()');
xlabel('X-Axis');
ylabel('Y-Axis');
zlabel('Z-Axis');Visualize clustered data points in three-dimensional space with color-mapped values and variable marker sizing:
% Generate 3D Gaussian Point Cloud x = randn(200, 1);
y = randn(200, 1);
z = randn(200, 1);
colorValues = sqrt(x.^2 + y.^2 + z.^2);
% Distance from origin
figure;
scatter3(x, y, z, 50, colorValues, 'filled');
colormap(parula);
colorbar;
grid on;
xlabel('X Coordinate');
ylabel('Y Coordinate');
zlabel('Z Coordinate');
title('3D Volumetric Scatter Plot with Color Mapping');Project contour lines onto 3D planes to visualize gradient contours alongside surfaces:
% Combined Surface and 3D Contour Plot [X, Y, Z] = peaks(30);
figure;
surfc(X, Y, Z);
% Draws surface with contours beneath colormap(turbo);
colorbar;
title('3D Surface with Projected Contours (surfc)');
xlabel('X');
ylabel('Y');
zlabel('Z');| Function | Plot Type | Primary Use Case |
|---|---|---|
plot3(x, y, z) |
3D Line / Curve | UAV trajectories, orbital paths, helical springs, time-series data. |
surf(X, Y, Z) |
Shaded 3D Surface | Continuous mathematical functions, terrain elevation, thermal distribution. |
mesh(X, Y, Z) |
3D Wireframe | Grid connectivity, FEM structural deformation, low-overhead 3D inspection. |
scatter3(x, y, z) |
3D Scatter Points | Point cloud datasets, LiDAR sensor scans, multi-feature clustering. |
surfc(X, Y, Z) |
Surface + Contours | Optimization landscapes, cost function visualization, saddle points. |
Our 500+ PhD engineers provide verified MATLAB code, custom Simulink models, and 1-on-1 tutoring with Turnitin plagiarism reports.
Real feedback from students across top engineering universities worldwide.
“I got full marks on my MATLAB DSP assignment! The filter design code was completely vectorized, the frequency response plots were exact, and the delivery was 8 hours before my deadline. Highly recommended!”
“Our Simulink EV powertrain model had severe algebraic loop and solver errors. The MATLABSolutions team fixed the solver configuration in 4 hours and provided an annotated scope diagram. Lifesaver for my final year!”
Explore deep-dive technical articles written by our engineering team to master complex MATLAB & Simulink topics.
Why Run CNNs on Cortex-M Processors? ARM Cortex-M cores power millions of edge sensors, industrial controllers, and medical wearables. Running 1D or 2D Convolutional N...
The Memory Wall on Edge Microcontrollers Standard neural networks store weights and compute activations using single-precision floating point (32-bit float...