Table of Contents

Introduction
A cursory introduction.
Getting started
A few bones hints that will help you become started.
Graphics Model
Creating a Graphics Window
The Camera Toolbar
Lighting
MATLAB Data Types
Modeling Visualization Algorithms
Matrix to Surface
Slicing
Scalar Visualization Algorithms
Color Mapping
Contours/Isosurfaces
Vector Visualization Algorithms
Oriented Glyphs
Stream Lines
Additional Help
References

Introduction

MATLAB is a high-performance linguistic communication for technical computing. It integrates ciphering, visualization, and programming in an easy-to-use environment where bug and solutions are expressed in common mathematical notation. MATLAB is an interactive organisation whose basic data blazon is the array or matrix.

MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as annotating and press these graphs. It includes high-level functions for 2-dimensional and three-dimensional data visualization, image processing, animation, and presentation graphics. There are ii basic ways to create graphs in MATLAB. Yous tin either employ the MATLAB GUI plotting tools to interactively create graphs (see Some Ways to Use Plotting Tools for more information) or yous can utilize the command interface by entering MATLAB graphics commands in the Control Window.

In this tutorial nosotros volition employ the command interface to show how to visualize scientific data using MATLAB graphics commands. Nosotros will cover major visualization techniques such as slicing, color mapping, contouring, oriented glyphs, and streamlines. Information technology is assumed that the educatee is familiar with the basics of using MATLAB.

For an introductory tutorial on using MATLAB, run across the SCV tutorial an Introduction to MATLAB. MathWorks, the developer of MATLAB, also has all-encompassing MATLAB documentation including video tutorials on its website. And there is a full set of documentation available from within MATLAB itself which tin be viewed by selecting Product Assist from the Assist menu.


Getting started

The well-nigh effective style for you to go through this tutorial is to run the listed case code in a MATLAB session as you proceed through the tutorial. This can be accomplished by copying and pasting the listed example code into the MATLAB Command Window. It will also exist helpful for you to browse the MATLAB documentation for the specific functions as we discuss them (links are provided). Afterwards browsing the documentation, you should then experiment with the instance code by varying some of the arguments and watching the effect this has on the output. Past playing with the case code, you will proceeds a deeper understanding of how the diverse graphic functions work.

Boston University SCV users, please get to the SCV MATLAB Assist Page for data specific to the installation at this site. This will tell you on what machines MATLAB is bachelor, how to set up your environment, how to ready your display, and where the documentation is.


Graphics Model

MATLAB has an abstract graphics layer above the local host's graphic software interface. This insures cross-platform portability and creates a device independent graphics layer. In MATLAB graphics objects are used to create visual representations of information. There are ii basic types of graphics objects in the MATLAB graphics model: Core graphics objects and Composite graphics objects. Core graphics objects include bones drawing primitives such as line, text, rectangles, patches (filled polygons), surfaces (3D grid of vertices), images (2d matrix representation of an image), calorie-free sources, and axes (define the coordinate system). Composite graphics objects are composed of core graphics objects that have been grouped together to provide a more convenient interface.

Creating a Graphics Window

In order to visualize your data, you will demand a graphics window which contains a figure, an axes, and a view.

Figure

All MATLAB graphical output is directed to a window that is split from the Control Window. This window is referred to equally a figure. Figures can comprise menus, toolbars, user-interface objects, context menus, axes, or whatever other type of graphics object. MATLAB functions that generate graphics output such equally plot, surf, slice, etc. will create a effigy if none already exists. If a figure does exist, then these functions will brandish their graphics output in the current figure window (the last effigy window used or clicked in). By default this will be done without clearing or resetting the current figure properties.

To create a new effigy, utilize the figure role. Here is example code to create a simple graphics window:

                      figure                  

figure1

Every graphics object has a prepare of properties associated with it. These properties define the different attributes of an object, such as its color, size, position, etc. Backdrop are usually specified by name/holding pairs east.g. figure( 'PropertyName', propertyvalue, ... ). These backdrop tin exist set either at the time of cosmos past specifying property name and property value pairs or after the graphics object has been created by using the prepare part.

When creating a new figure, MATLAB creates a window whose characteristics are specified by your calculator'south windowing arrangement, by the default MATLAB figure properties, and by the properties specified as arguments to the function. Any property non specified every bit an argument will utilise the default values. See the Figure Properties for a list of properties that tin can be gear up for a figure.

Here is an example of setting figure properties to create a new window named 'Test Window' with no menus and with a screen position of [left 100, lesser 500, width 250, height 250]:

                      figure('Name','Test Window','Position',[100 500 350 350],'MenuBar','none')        

figure2

You can employ clf (articulate effigy) to clear the contents of the current figure and reset all of its properties to their default values.

                      clf            reset        

Axes

Axes define a frame of reference for the display objects in the figure window. This frame of reference is the coordinate system which defines where each information indicate is placed on the graph. Axes orient and calibration graphical output to produce the view of the data that you lot come across on screen. Past default, the size of the axes MATLAB creates is normalized to the size of the figure window. All functions that draw graphics create an axes object if one does non already exist.

As with figure properties, axes properties are used to specify the characteristics of the axes. The Axes Backdrop list all axes properties and provide an overview of the characteristics that are affected by each property. For example photographic camera properties such as the photographic camera position, camera target, up vector, and view angle tin all be directly set with axes properties. The axes part, however, is a low-level function. Though you tin specify values for these properties directly, it is much easier to employ the view function (covered in the next department) to set up the axes using default belongings values and to define a reasonable view.

View

The view is the detail orientation yous gear up to display the visualization. The term viewing refers to the process of displaying a graphical scene from diverse directions by adjusting the photographic camera position, irresolute the perspective, changing the aspect ratio, etc.

MATLAB viewing is composed of ii basic areas:

  • Positioning the viewpoint to orient the scene
  • Setting the aspect ratio and relative axis scaling to command the shape of the objects being displayed

Positioning the viewpoint: The view function specifies the viewpoint past defining azimuth and top with respect to the axis origin. Azimuth is a polar angle in the x-y plane, with positive angles indicating counterclockwise rotation of the viewpoint. Top is the angle to a higher place (positive bending) or below (negative bending) the x-y airplane.

coordinates

MATLAB automatically selects a viewpoint that is determined by whether the plot is two-D or 3-D:

  • For two-D plots, the default is azimuth = 0° and elevation = 90°.
  • For 3-D plots, the default is azimuth = -37.v° and elevation = 30°.

view(ii) sets the default two-dimensional view, with az = 0, el = 90.
view(three) sets the default three-dimensional view, with az = –37.v, el = 30.
view(az,el) or view([az,el]) set the viewing angle for a three-dimensional plot.

The azimuth, az, is the horizontal rotation about the z-centrality as measured in degrees from the negative y-centrality. Positive values indicate counterclockwise rotation of the viewpoint. el is the vertical elevation of the viewpoint in degrees. Positive values of elevation correspond to moving above the object; negative values correspond to moving below the object.

Here is case code that creates a uncomplicated graphics window with a default axes, a view, and a surface:

          Z =            peaks(20);            figure; h =            surf(Z);                          view([-20,25]);                  

figur33

Setting the aspect ratio and axis scale: The centrality command enables yous to accommodate the aspect ratio of graphs. The axis command also enables you to adapt the scaling of graphs. Normally MATLAB stretches the axes to fill up the window and chooses appropriate axes ranges based on the maxima and minima of the plotted data. If you will be interactively rotating the visualization in the figure window y'all should use the vis3d option.

axis([xmin xmax ymin ymax zmin zmax]) sets the limits for the 10-axis, y-axis and z-axis of the current axes.
axis vis3d freezes aspect ratio properties to enable rotation of iii-D objects and overrides stretch-to-fill.

Hither is the aforementioned code just with a different axes:

          Z =            peaks(20);            figure; h =            surf(Z);            view([-xx,25]);                          axis([0 30 0 30 -15 xv]);                  

figure4

Labels

The xlabel, ylabel, and zlabel commands add x-, y-, and z-axis labels. The title command adds a title at the elevation of the figure and the text part inserts text anywhere in the figure.

Hither is example code that creates a simple graphics window with a default axes, a default view, a surface, and labels:

          Z =            peaks(twenty);            effigy; h =            surf(Z);            view(3);            axis            on;                          xlabel('Longitude');              ylabel('Breadth');              zlabel('Distance');              title('Surface of Peaks');                  

figure5

The Camera Toolbar

Once you lot take established the initial view for your visualization, you lot can and so use the Camera toolbar to interactively command the camera. To enable the Camera toolbar, select Photographic camera Toolbar from the figure window's View carte. Your effigy window should now look like this:

figure6

This camera toolbar contains the post-obit parts:

camera toolbar

Meet View Control with the Camera Toolbar for data on how to use the camera toolbar.

Lighting

Lighting is an effective ways to raise the visibility of surface shape and to provide a three-dimensional perspective to your visualization. MATLAB provides several commands that enable y'all to position light sources and adapt the characteristics of lit objects. These commands include the following:

lite – Creates a light object

lighting – Selects a lighting method

fabric – Sets the reflectance properties of lit objects

camlight – Creates or moves a light with respect to the camera position

shading – Controls the color shading of surface and patch graphic objects

Here is example code that creates a simple graphics window with a default axes, a default view, a surface, and a camera light with phong shading:

          Z =            peaks(20);            effigy; h =            surf(Z);            view(iii);            centrality            on;                          light;              lighting              phong;              camlight('left');              shading              interp;                  

img


MATLAB Data Types

Matrix

The fundamental data type of MATLAB is the matrix or array. A matrix is an north row by chiliad column array of numbers or objects corresponding to numbers:

                      >>            a = [ 1 ii 3 ; 4 5 6 ; seven 8 9]                          a =     1   2   three    four   v   vi    7   eight   9                  

When n is 1 the matrix is a row vector:

                      >>            b = [1 two 3]            b =    1   2   three                  

When thou is 1 the matrix is a column vector:

                      >>            c = [i; 2; iii]            c =    1   2   3                  

and when both n and m are 1 the 1 ten i matrix corresponds to a scalar.

                      >>            d = [1]            d =    ane                  

MATLAB uses graphics objects to create visual representations of information. Arrays of numbers can be used not simply to store scalar and vector information but likewise the coordinate information of graphics objects. For example a ii-dimensional assortment of numbers could exist used to represent a surface by amalgam a grid of rectangles whose vertices are divers by using the row and column indices of each element every bit the x– and y-coordinates and the value of each element as the z-coordinate.

Volume Data
MATLAB uses the term "Volume Visualization" to refer to the graphical representation of data sets that are defined on iii-dimensional grids. These data sets are characterized by multidimensional arrays of scalar or vector data and are typically defined on lattice structures representing values sampled in 3-D space.
MATLAB has ii basic types of volume data:

  • Scalar volume data
  • single values for each point
  • examples: temperature, pressure level, density, superlative
  • Vector volume data
  • two or three values for each betoken, defining the components of a vector
  • magnitude and direction
  • examples: velocity, momentum

As an example of scalar volume data, we will be using the the flow Yard-file (M-files are text files containing MATLAB lawmaking). The flow dataset represents the speed profile of a submerged jet within an infinite tank.

                      >>            [x,y,z,v] =            period;        

The period dataset contains 4 3-D arrays: 10, y, and z are coordinate arrays which specify the coordinates of each point in the volume and v specifies the scalar value for each betoken in the volume.
As an example of vector book data, we will be using the wind dataset. The wind dataset represents air currents over North America and is stored equally a binary file. The load role imports variables containing numeric data from binary files or text files to the workspace.

                      >>            load            current of air        

The current of air dataset contains six 3-D arrays: x, y, and z are coordinate arrays which specify the coordinates of each betoken in the volume and u, v, and west are the vector components for each betoken in the book.
Both the flow and air current datasets are part of the example data included in the MATLAB installation.


Modeling Visualization Algorithms

Modeling algorithms are often used to reveal internal details of a information prepare in order to discover where interesting regions exist.

Matrix to Surface
In MATLAB a surface is defined by the z-coordinates of points above a rectangular grid in the 10y aeroplane. The surface is formed past joining adjacent points with straight lines. Surface plots are useful for visualizing large matrices and for graphing functions of two variables. In MATLAB there are 2 unlike types of surface plots: mesh plots and surface plots. Mesh plots are colored wire-frame surfaces. Surface plots are colored faceted surfaces.
The mesh and surf functions create 3-D surface plots of matrix data. For the matrix Z the elements Z(i,j) define the peak of a surface over an underlying (i,j) grid.
Surface properties provide boosted control over the visual appearance of the surface. You can specify line styles, face coloring, lighting characteristics, etc.
The meshgrid office generates X and Y arrays for 3-D plots.
The peaks function is a function of two variables, obtained by translating and scaling Gaussian distributions.

          [X,Y] =            meshgrid(-3:0.25:3); Z =            peaks(X,Y);            figure;                          mesh(Ten,Y,Z);            view(3);            axis([-3 3 -3 iii -10 10]);            filigree            on;        

mesh

          [X,Y] =            meshgrid(-3:0.25:three); Z =            peaks(X,Y);            figure;                          surf(Ten,Y,Z);              view(3);              axis([-3 iii -3 3 -x 10]);              grid              on;              lite;              lighting              phong;              camlight('left');                  

surface

Slicing
Slicing entails creating a "cross-department" of the dataset. Whatsoever kind of surface can be used to slice the volume, merely the simplest technique is to apply a plane to define the cut surface thereby creating a planar cut. The color at each point is determined past 3-D interpolation into the volume. The cut surface interpolates the data every bit it cuts in order to color the surface with values in the volume data where the slice is positioned. To create a planar cut we volition apply the slice part to practise the actual cutting.

          [x,y,z,v] =            menses;            figure;            xslice = 5; yslice = 0; zslice = 0;              slice(ten,y,z,v,xslice,yslice,zslice);            view(3);            centrality            on;            grid            on;            low-cal;            lighting            phong;            camlight('left');            shading            interp;        

slice


Scalar Visualization Algorithms

Scalars are unmarried data values associated with each point in the dataset. There are several different algorithms to visualize scalar data. 2 common algorithms are Color Mapping and Contouring.

Color Mapping
Color can be quite effective at conveying information values, both constant and varying. Colour mapping is a visualization technique in which each scalar value in the data gear up is mapped through a lookup table to a specific colour. The scalar values are used every bit an index into the color lookup table. In MATLAB the color lookup table is called the colormap. Each MATLAB effigy window has a colormap associated with it. The colormap is a iii-column two-D matrix whose length is equal to the number of colors that are defined. Each row of the matrix defines a unmarried color past specifying three values in the range of zero to one. These values ascertain the RGB components (i.e., the intensities of the cerise, green, and blue video components) of each colour.
The primary MATLAB part used for color mapping is colormap. Colormaps tin can exist created with either MATLAB assortment operations or with one of the several color tabular array generating functions (jet, hsv, hot, absurd, summer, and greyness). Each of the color tabular array generating functions has an optional parameter that specifies the number of colors or rows in the resulting colormap. The colorbar function displays the current color scalar mapping, either vertically or horizontally, in the figure window. Here is case code which shows the mapping of the unabridged scalar range of the data into the jet colour table:

          [ten,y,z,v] =            flow;            figure; xslice = 5; yslice = 0; zslice = 0;            slice(10,y,z,v,xslice,yslice,zslice);            view(3);            axis([0 10 -4 4 -3 3]);            grid            on;                          colormap(jet(64));              colorbar('vertical');            shading            interp;        

colormap

If instead of mapping the lower scalar values to dejection and the higher values to reds, we wish to map the lower values to reds and higher values to blues we tin use the flipud part. Hither is example code which shows the technique:

          [x,y,z,5] =            flow;            figure; xslice = 5; yslice = 0; zslice = 0;            slice(10,y,z,v,xslice,yslice,zslice);            view(3);            axis([0 ten -4 4 -three 3]);            grid            on;                          colormap(flipud(jet(64)));              colorbar('vertical');            shading            interp;        

colormap2

And if instead of mapping the unabridged scalar range of the data into the color table, we wish to gear up a specific range (in terms of minimum and maximum) of the data that is mapped, we can adjust the color limits. Adjusting the color limits with the caxis role enables u.s.a. to emphasize a particular range of interest in the information. Here is case code which shows the outcome of limiting the color range from -5.0 to ii.0 so that any scalar value lower than -5.0 are mapped to the aforementioned color as -5.0 and whatever scalar value greater than 2.0 are mapped to the same colour equally 2.0:

          [x,y,z,5] =            flow;            figure; xslice = 5; yslice = 0; zslice = 0;            slice(x,y,z,v,xslice,yslice,zslice); view(3); axis([0 10 -four 4 -3 3]); grid on;                          colormap(flipud(jet(64)));              caxis([-5.0,2.0]);              colorbar('vertical');            shading            interp;        

colormap3

If you desire fifty-fifty more control over the colour mapping, yous tin use the colormap editor. You lot open the colormap editor by selecting Colormap from the Edit carte du jour of the figure whose colormap yous wish to alter.

color map editor

The colormap editor displays the current figure's colormap as a strip of colored cells. Node pointers are located below the colormap strip and signal points in the colormap where the rate of the variation of R, G, and B values changes. Yous tin can select and move the node pointers to change the range of colors in the colormap. The color of a node arrow remains constant equally you move it, but the colormap changes by linearly interpolating the RGB values between nodes. Y'all tin can likewise add a node pointer by clicking beneath the corresponding cell in the colormap strip.
Here is an instance of using the color map editor:
color map editor 2

colormap4

Contours / Isosurfaces
Contouring is a technique where ane constructs a boundary between distinct regions in the data. Contours are lines or surfaces of constant scalar value. This is a natural extension from colour mapping as our eyes instinctively separate similarly colored areas into distinct regions. The outset step in contouring is to explore the data space to find points nearly a contour or region of interest. One time found these points are then connected into either profile lines (isolines) for 2-dimensional data or into surfaces (isosurfaces) for iii-dimensional data. The lines or surfaces can also be color mapped using the scalar data. The primary MATLAB functions used for creating profile lines are contour and contour3 and contourslice.
contour(X,Y,Z,v) draws a profile plot of matrix Z with profile lines at the data values specified in the vector v.
contour3(X,Y,Z,v) draws a contour plot of matrix Z in a 3-D view using X and Y to determine the x- and y-axis limits.
contourslice(X,Y,Z,V,Sx,Sy,Sz,v) draws contour plots in the 10-, y-, and z-axis aligned planes at the points in the vectors Sx, Sy, Sz.

Here are some examples which shows how to generate contours for two-dimensional data:

          [Ten,Y] =            meshgrid(-three:0.25:iii); Z =            peaks(Ten,Y);            effigy;            isovalues = (-3.0:0.5:three.0);              contour(X,Y,Z,isovalues);            view(two);            axis            on;            grid            on;        

contour1

          [10,Y] =            meshgrid(-3:0.25:3); Z =            peaks(X,Y);            figure;            isovalues = (-3.0:0.v:3.0);              contour3(X,Y,Z,isovalues);            view(3);            axis            on;            filigree            on;        

contour2

          [x,y,z,v] =            menses;            effigy;            xslice = (1:3:nine); yslice = 0; zslice = 0; isovalues = (-iii.0:0.25:3.0);              contourslice(x,y,z,v,xslice,yslice,zslice,isovalues);            view([-10 forty]);            axis            on;            grid            on;        

contour3

For 3-dimensional data we can generate an isosurface. Through exploration of the volume information, we tin decide isovalues that reveal useful data about the data. To get-go select an isovalue within the range of values in the volume data. The primary MATLAB functions used for creating isosurfaces are isosurface, isonormals, and patch.
isosurface(10,Y,Z,V,isovalue) computes isosurface data from the volume data 5 at the isosurface value specified in isovalue. The isosurface function connects points that have the specified value the same way contour lines connect points of equal elevation.
isosurface(X,Y,Z,V,isovalue,colors) computes isosurface information and also interpolates the array colors onto the scalar field and colors the isosurface appropriately.
isonormals(X,Y,Z,V,vertices) computes the normals of the isosurface vertices from the vertex list necessary for lighting.
patch is the depression-level graphics role that creates patch graphics objects. A patch object is one or more polygons divers by the coordinates of its vertices.

In this example we testify how to create a single colored isosurface:

          [x,y,z,v] =            flow;            isovalue = -ane; purple = [1.0 0.5 1.0];            figure;            p =              patch(isosurface(x,y,z,5,isovalue));              isonormals(x,y,z,five,p);              ready(p,'FaceColor',imperial,'EdgeColor','none');            view([-10 40]);            axis            on;            grid            on;            light;            lighting            phong;            camlight('left');        

isosurface1

In this side by side example we create two isosurfaces and colour each of them by using the v scalar information of the menstruum dataset and the electric current colormap. The fcolors variable is a vector containing scalar values for each of the vertices in the isosurface.

                      [x,y,z,v] =            flow;            isovalue = -one; colors = five;            figure;            [faces,verts,fcolors] =              isosurface(ten,y,z,v,isovalue,colors); p =              patch('Vertices',verts,'Faces',faces,'FaceVertexCData',fcolors, ... 'FaceColor','interp','EdgeColor','none');              isonormals(10,y,z,v,p); isovalue2 = 0; [faces,verts,fcolors] =              isosurface(x,y,z,v,isovalue2,colors); p2 =              patch('Vertices',verts,'Faces',faces,'FaceVertexCData',fcolors, ... 'FaceColor','interp','EdgeColor','none');              isonormals(x,y,z,5,p2);            view([-x 40]);            centrality            on;            grid            on;            colormap(jet(64));            low-cal;            lighting            phong;            camlight('left');        

isosurface2


Vector Visualization Algorithms

Vector data is a three-dimensional representation of direction and magnitude associated with each betoken in the dataset. Vector information is frequently used to describe rate of alter of some quantity. Vectors tin can also be used to describe fluid menstruum. In that location are several algorithms that tin be used to visualize vector information.

Oriented Glyphs
One visualization technique for vector information is to draw an oriented, scaled glyph for each vector. The orientation and calibration of the glyph tin can signal the direction and magnitude of the vector. The glyph may also be colored co-ordinate to vector magnitude or some other scalar quantity (east.m. temperature or pressure). Glyphs are polygonal objects such equally a cone or an arrow. In MATLAB there are currently two types of glyph available: the cone or the arrow. The primary MATLAB function for creating oriented glyph visualizations is coneplot.
coneplot(X,Y,Z,U,V,W,Cx,Cy,Cz) plots vectors equally cones pointing in the direction of the vector, having a length proportional to the magnitude of the vector.
10, Y, Z define the coordinates for the vector field
U, V, W define the vector field
Cx, Cy, Cz ascertain the location of the cones in the vector field
See Specifying Starting Points for Stream Plots for tips on how to select starting locations.
coneplot(...,s) automatically scales the cones to fit the graph and so stretches them by the scale factors. If you do non specify a value for s, a value of 1 is used. Use s = 0 to plot the cones without automatic scaling.
coneplot(...,color) interpolates the array color onto the vector field and then colors the cones co-ordinate to the interpolated values. The size of the color array must be the same size every bit the U, V, Due west arrays. This selection only works with cones.
coneplot(...,'quiver') draws arrows instead of cones.

This example uses pointer glyphs to visualize the vector data. The arrows are scaled (proportional to the magnitude of the vectors) and are located over the entire book.

                      load            wind; xmin = min(x(:)); xmax = max(x(:)); ymin = min(y(:)); ymax = max(y(:)); zmin = min(z(:)); zmax = max(z(:)); scale = four;            figure;            [cx cy cz] =              meshgrid(xmin:5:xmax,ymin:5:ymax,zmin:2:zmax);              coneplot(ten,y,z,u,v,west,cx,cy,cz,calibration,'quiver');            view([-35 lx]);            camproj            perspective;            camzoom(3.0);            axis            on;            filigree            off;            box            on;        

glyph1

This example uses cone glyphs to visualize the vector information. The cones are colored by air current speed.

                      load            air current; xmin =            min(x(:)); xmax =            max(x(:)); ymin =            min(y(:)); ymax =            max(y(:)); zmin =            min(z(:)); zmax =            max(z(:)); wind_speed =            sqrt(u.^2 + v.^2 + w.^2); colors = wind_speed; scale = iv;            figure;            [cx cy cz] =              meshgrid(xmin:5:xmax,ymin:5:ymax,zmin:2:zmax); c =              coneplot(x,y,z,u,5,w,cx,cy,cz,scale,colors);              prepare(c,'EdgeColor','none');            view([-35 60]);            camproj            perspective;            camzoom(3.0);            axis            on;            grid            off;            box            on;            light;            lighting            flat;        

glyph2

Streamlines
A streamline can be thought of equally the path a massless particle takes flowing through a velocity field (i.due east. vector field). Streamlines can be used to convey the construction of a vector field by providing a snapshot of the menstruum at a given instant in time. Multiple streamlines can be created to explore interesting features in the field. Streamlines are computed via numerical integration (integrating the product of velocity times delta T). The primary MATLAB functions used for creating streamline visualizations are streamline, streamribbon, and streamtube.
streamline(X,Y,Z,U,V,W,startx,starty,startz) draws stream lines from the vector volume data.
streamribbon(X,Y,Z,U,V,W,startx,starty,startz) draws stream ribbons from the vector volume data.
streamtube(X,Y,Z,U,5,W,startx,starty,startz) draws stream tubes from the vector book data.
Ten, Y, Z define the coordinates for the vector field
U, Five, Due west ascertain the vector field
startx, starty, startz define the starting positions of the streams
Meet Specifying Starting Points for Stream Plots for tips on how to select starting locations.

This example uses stream lines to visualize the vector data.

                      load            wind; xmin =            min(10(:)); xmax =            max(x(:)); ymin =            min(y(:)); ymax =            max(y(:)); zmin =            min(z(:)); zmax =            max(z(:)); purple = [1.0 0.5 one.0];            figure;            [sx sy sz] =              meshgrid(xmin,ymin:ten:ymax,zmin:2:zmax); h =              streamline(x,y,z,u,five,due west,sx,sy,sz);              gear up(h,'LineWidth',i,'Color',imperial);            view([-40 50]);            axis            on;            grid            off;            box            on;        

stream1

This case uses stream ribbons to visualize the vector data. The ribbons are colored past the magnitude of the vectors.

                      load            wind; xmin =            min(x(:)); xmax =            max(x(:)); ymin =            min(y(:)); ymax =            max(y(:)); zmin =            min(z(:)); zmax =            max(z(:));            figure;            [sx sy sz] =              meshgrid(xmin,ymin:x:ymax,zmin:2:zmax) h =              streamribbon(ten,y,z,u,v,due west,sx,sy,sz);              set(h,'EdgeColor','none');            view([-40 l]);            axis            on;            grid            off;            box            on;            low-cal;            lighting            flat;            camlight('left');        

stream2

This example uses stream tubes to visualize the vector data. The width of the tubes are proportional to the normalized departure of the vector field.

                      load            wind; xmin =            min(ten(:)); xmax =            max(x(:)); ymin =            min(y(:)); ymax =            max(y(:)); zmin =            min(z(:)); zmax =            max(z(:));            figure;            [sx sy sz] =              meshgrid(xmin,ymin:10:ymax,zmin:ii:zmax); h =              streamtube(x,y,z,u,v,w,sx,sy,sz);              set(h,'EdgeColor','none');            view([-40 l]);            centrality            on;            grid            off;            box            on;            light;            lighting            flat;            camlight('left');        

stream3


Additional Help

For an introductory tutorial on using MATLAB, see the SCV tutorial an Introduction to MATLAB.
MathWorks, the developer of MATLAB, has extensive MATLAB Technical Documentation and Support including user guides, video tutorials, and demos on its website.
There is a full set up of documentation bachelor from within MATLAB itself which can be viewed past selecting Product Help from the Assistance card.
For specifics on running MATLAB on SCV systems, see our MATLAB Help Page.
For more information on MATLAB, visit the MATLAB website or the MATLAB Wiki.
In that location are also several other MATLAB tutorials bachelor on the web: MATLAB Tutorials.


References

All of the data covered in this tutorial was taken either from the standard MATLAB documentation or from the MathWorks website. Our goal was to simplify and reduce the amount of information you need to understand in guild to get-go visualizing your information.
Getting Started with MATLAB, version 7, The MathWorks, Inc.

Using MATLAB, version 7, The MathWorks, Inc.

Using MATLAB Graphics, version vii, The MathWorks, Inc.

MathWorks: MATLAB Technical Documentation and Support