logo for matrixlab-examples.com
[?] Subscribe To This Site

XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines


Home
Welcome Matrixmania Blog
-> Sitemap / Search <-
-> Books <-
Forums and Help
Contact
Basics Quick Matlab Guide
Matlab Tutorial
Matlab Examples
Matlab Flow Control
Boolean Logic
Plots and GUI Matlab 2D Plots
Matlab 3D Plots
Matlab GUI
Applications Calculus
Linear Algebra
Matlab Cookbook I
Matlab Cookbook II
Electrical Calculations
Probability and Stats
Finance Apps
Other Relevant Links
Notes on Computing
Online Calculators
Fun!
Your own Website?
Terms/Policies
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.

Example:



% 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
figure(1)
contour3(x,y,z)

% opens figure 2 and draws the function using a mesh
figure(2)
mesh(x,y,z)

% opens figure 3 and draws the function using surface with contours
figure(3)
surfc(x,y,z)

% opens figure 4 and draws the function using a enlightened surface
figure(4)
surfl(x,y,z)
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

Top

Part 1 -view, grid, subplot

Part 2 -meshgrid, plot3, meshc, surfc

Part 3 - plot3, sphere

3D animation



footer for matlab page