K10765 Matlab 3D Mesh Plots

11

Click here to load reader

Transcript of K10765 Matlab 3D Mesh Plots

Page 1: K10765 Matlab 3D Mesh Plots
Page 2: K10765 Matlab 3D Mesh Plots

*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

Page 3: K10765 Matlab 3D Mesh Plots

•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!

Page 4: K10765 Matlab 3D Mesh Plots

•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.

Page 5: K10765 Matlab 3D Mesh Plots

•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)

Page 6: K10765 Matlab 3D Mesh Plots

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)

Page 7: K10765 Matlab 3D Mesh Plots
Page 8: K10765 Matlab 3D Mesh Plots

% 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')

Page 9: K10765 Matlab 3D Mesh Plots
Page 10: K10765 Matlab 3D Mesh Plots

•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

Page 11: K10765 Matlab 3D Mesh Plots