Water Industry Process Automation & Control Monthly - April 2024
Â
K10765 Matlab 3D Mesh Plots
1.
2. *It is a high-level language for numerical computation, visualization and application
development.
*It also provides an interactive environment for iterative exploration, design and
problem solving.
â˘It provides vast library of mathematical functions for linear algebra, statistics,
Fourier analysis, filtering, optimization, numerical integration and solving ordinary
differential equations.
*It provides built-in graphics for visualizing data and tools for creating custom plots.
*MATLAB's programming interface gives development tools for improving code
quality, maintainability, and maximizing performance.
*It provides tools for building applications with custom graphical interfaces.
*It provides functions for integrating MATLAB based algorithms with external
applications and languages such as C, Java, .NET and Microsoft Excel.
MATLAB
3. â˘Plotting in 3D and 3D data visualization is where Matlabâs power really
becomes apparent!
â˘Matlab defines a number of different kinds of 3D plots but you will
probably find 3 or 4 to be the most useful:
â˘x,y,z 3D line plot: plot3( )
â˘mesh plot: mesh( )
â˘surface plot: surf( )
â˘contour plot: contour( )
â˘combo surface/mesh with contour: surfc( )
â˘The surface plotting can also be applied to create realistic 3D objects by
defining and plotting their exterior surfaces!
4. â˘It is often desirable to plot functions of the form: z=f(x,y)
â˘for each (x,y), we can compute a value for z
â˘this defines a surface in 3D space
â˘If we can define (x,y) at regular intervals, Matlab provides powerful ways to
plot the resulting function as a mesh or surface in 3D
â˘The (x,y) values stored in arrays will define a grid of mesh points through
which the surface will be created.
5. â˘3D plotting introduces several key concepts:
â˘Meshes versus Surfaces
â˘Hidden line removal
â˘Pedestals and contours
â˘Color maps and pseudo-coloring
â˘Viewpoints and camera control (advanced!)
â˘Shading and lighting (advanced)
6. Create a grid of x and y points
points = linspace(-2, 2, 40);
Y, Z) X, Y] = meshgrid(points, points);
% Define the function
Z = f(X,Y) Z = 2./exp((X-.5).^2+Y.^2)-2./exp((X+.5).^2+Y.^2);
% Create the surface plot using the surf command figure surf(X, Y,
Z)
7.
8. % Create a grid of x and y data
y = -10:0.5:10;
x = -10:0.5:10;
[X, Y] = meshgrid(x, y);
% Create the function values for Z = f(X,Y)
Z = sin(sqrt(X.^2+Y.^2)) ./ sqrt(X.^2+Y.^2);
% Create a surface contour plor using the surfc function
figure
surfc(X, Y, Z)
% Adjust the view angle
view(-38, 18)
% Add title and axis labels
title('Normal Response')
xlabel('x')
ylabel('y')
zlabel('z')
9.
10. â˘Uses of 3-D plots in MATLAB
â˘Well MATLAB is widely used as a computational tool in science and
engineering encompassing the fields of physics, chemistry, math and all
engineering streams. It is used in a range of applications including:
⢠signal processing and Communications
⢠image and video Processing
⢠control systems
⢠test and measurement
⢠computational finance
⢠computational biology