logo for matrixlab-examples.com
leftimage for matrixlab-examples.com

3D plot – Part 4

Different built-in functions to deal with tridimensional graphs.

In this example we make a summarization of the use of the following 3D plot instructions:

•    meshgrid
•    figure
•    contour3
•    mesh
•    surfc
•    surfl

It is better if you've already read Parts 1 to 3. We're plotting exactly the same 3D
data (a function depending on two variables) using several instructions, so the visualization is pretty different from each other.


% cleans the memory workspace
clc; clear; close all;

% defines the range of axes x and y
vx = -3 : 0.1 : 3;
vy = vx;

% generates the powerful grid
[x, y] = meshgrid(vx, vy);

% defines the function to be plotted
z = -10 ./ (3 + x.^2 + y.^2);

% opens figure 1 and plots the function using only contours

% opens figure 2 and draws the function using a mesh

% opens figure 3 and draws the function using surface with contours

% opens figure 4 and draws the function using a enlightened surface
shading interp
colormap hot

The resulting 3D graphics are:

Matlab 3D plot using contour3

3D plot using mesh

3D plot using surfc

3D plot using surl, with shading and colormap

From '3D Plot Part 4' to home

From '3D Plot Part 4' to 3D Main


Part 1 -view, grid, subplot

Part 2 -meshgrid, plot3, meshc, surfc

Part 3 - plot3, sphere

3D animation

footer for matlab page