Table of Contents

Introduction
A cursory introduction.
Getting started
A few basic hints that will assistance you go 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
Boosted Help
References

Introduction

MATLAB is a high-performance language for technical calculating. It integrates computation, visualization, and programming in an like shooting fish in a barrel-to-employ environment where problems and solutions are expressed in common mathematical notation. MATLAB is an interactive system whose basic information blazon is the array or matrix.

MATLAB has extensive facilities for displaying vectors and matrices equally graphs, equally well every bit annotating and press these graphs. It includes high-level functions for two-dimensional and three-dimensional data visualization, prototype processing, animation, and presentation graphics. There are two basic means to create graphs in MATLAB. You can either utilize the MATLAB GUI plotting tools to interactively create graphs (run into Some Means to Use Plotting Tools for more data) or you can use the control interface past inbound MATLAB graphics commands in the Command Window.

In this tutorial we will use the control interface to show how to visualize scientific data using MATLAB graphics commands. We will cover major visualization techniques such equally slicing, colour mapping, contouring, oriented glyphs, and streamlines. It is assumed that the student is familiar with the nuts of using MATLAB.

For an introductory tutorial on using MATLAB, see the SCV tutorial an Introduction to MATLAB. MathWorks, the programmer of MATLAB, also has extensive MATLAB documentation including video tutorials on its website. And there is a total gear up of documentation bachelor from within MATLAB itself which can be viewed by selecting Product Help from the Assist menu.


Getting started

The nearly effective way for y'all to go through this tutorial is to run the listed example lawmaking in a MATLAB session as you proceed through the tutorial. This can be achieved by copying and pasting the listed example code into the MATLAB Command Window. It volition also be helpful for you to scan the MATLAB documentation for the specific functions every bit we discuss them (links are provided). Afterwards browsing the documentation, you should so experiment with the example code past varying some of the arguments and watching the effect this has on the output. By playing with the example lawmaking, you lot volition proceeds a deeper understanding of how the diverse graphic functions work.

Boston University SCV users, please go to the SCV MATLAB Assistance Folio for information specific to the installation at this site. This will tell you on what machines MATLAB is bachelor, how to prepare up your environment, how to set 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 contained graphics layer. In MATLAB graphics objects are used to create visual representations of information. There are 2 bones types of graphics objects in the MATLAB graphics model: Core graphics objects and Composite graphics objects. Core graphics objects include basic drawing primitives such as line, text, rectangles, patches (filled polygons), surfaces (3D grid of vertices), images (second matrix representation of an prototype), calorie-free sources, and axes (ascertain the coordinate organisation). Composite graphics objects are composed of core graphics objects that take been grouped together to provide a more user-friendly interface.

Creating a Graphics Window

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

Figure

All MATLAB graphical output is directed to a window that is separate from the Command Window. This window is referred to as a figure. Figures tin contain menus, toolbars, user-interface objects, context menus, axes, or whatever other blazon of graphics object. MATLAB functions that generate graphics output such as plot, surf, piece, etc. will create a figure if none already exists. If a figure does exist, so these functions will display their graphics output in the current figure window (the last figure window used or clicked in). Past default this will be done without clearing or resetting the current effigy properties.

To create a new figure, use the figure role. Here is case code to create a simple graphics window:

                      figure                  

figure1

Every graphics object has a set of properties associated with information technology. These properties define the different attributes of an object, such as its colour, size, position, etc. Backdrop are usually specified past proper noun/property pairs e.g. figure( 'PropertyName', propertyvalue, ... ). These properties can be set either at the time of creation past specifying property name and property value pairs or after the graphics object has been created past using the set part.

When creating a new figure, MATLAB creates a window whose characteristics are specified by your computer's windowing system, by the default MATLAB figure properties, and by the properties specified as arguments to the function. Whatsoever holding not specified as an statement volition use the default values. See the Effigy Backdrop for a list of properties that can be set for a figure.

Hither is an example of setting effigy backdrop to create a new window named 'Examination Window' with no menus and with a screen position of [left 100, lesser 500, width 250, height 250]:

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

figure2

You lot can use clf (articulate figure) to clear the contents of the electric 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 data point is placed on the graph. Axes orient and scale graphical output to produce the view of the data that y'all see on screen. By 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 i does not already exist.

As with figure backdrop, 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 holding. For example photographic camera backdrop such every bit the camera position, camera target, up vector, and view angle tin can all be directly set with axes properties. The axes function, however, is a low-level office. Though you can specify values for these properties directly, it is much easier to use the view function (covered in the next department) to set up the axes using default property values and to define a reasonable view.

View

The view is the particular orientation you ready to brandish the visualization. The term viewing refers to the procedure of displaying a graphical scene from various directions past adjusting the camera position, changing the perspective, irresolute the aspect ratio, etc.

MATLAB viewing is equanimous of two bones 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 part specifies the viewpoint by defining azimuth and tiptop with respect to the centrality origin. Azimuth is a polar bending in the x-y plane, with positive angles indicating counterclockwise rotation of the viewpoint. Elevation is the bending above (positive angle) or beneath (negative angle) the x-y plane.

coordinates

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

  • For 2-D plots, the default is azimuth = 0° and meridian = ninety°.
  • For three-D plots, the default is azimuth = -37.5° and acme = xxx°.

view(2) sets the default ii-dimensional view, with az = 0, el = ninety.
view(three) sets the default 3-dimensional view, with az = –37.five, 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 near the z-axis every bit measured in degrees from the negative y-axis. Positive values indicate counterclockwise rotation of the viewpoint. el is the vertical elevation of the viewpoint in degrees. Positive values of elevation represent to moving above the object; negative values represent to moving beneath the object.

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

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

figur33

Setting the aspect ratio and axis calibration: The axis control enables you to adjust the aspect ratio of graphs. The axis command besides enables you to suit the scaling of graphs. Ordinarily MATLAB stretches the axes to make full the window and chooses advisable axes ranges based on the maxima and minima of the plotted data. If you will be interactively rotating the visualization in the figure window you should use the vis3d pick.

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

Here is the same lawmaking but with a different axes:

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

figure4

Labels

The xlabel, ylabel, and zlabel commands add x-, y-, and z-centrality labels. The title command adds a title at the summit of the figure and the text function 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(20);            figure; h =            surf(Z);            view(3);            axis            on;                          xlabel('Longitude');              ylabel('Latitude');              zlabel('Altitude');              title('Surface of Peaks');                  

figure5

The Photographic camera Toolbar

Once yous take established the initial view for your visualization, you tin then utilise the Camera toolbar to interactively command the camera. To enable the Camera toolbar, select Camera Toolbar from the figure window's View menu. Your effigy window should now look like this:

figure6

This camera toolbar contains the post-obit parts:

camera toolbar

Run across View Control with the Camera Toolbar for information on how to use the camera toolbar.

Lighting

Lighting is an effective ways to enhance the visibility of surface shape and to provide a three-dimensional perspective to your visualization. MATLAB provides several commands that enable you to position lite sources and adjust the characteristics of lit objects. These commands include the post-obit:

light – Creates a light object

lighting – Selects a lighting method

material – Sets the reflectance backdrop of lit objects

camlight – Creates or moves a calorie-free with respect to the photographic camera position

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

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

          Z =            peaks(20);            figure; h =            surf(Z);            view(3);            axis            on;                          lite;              lighting              phong;              camlight('left');              shading              interp;                  

img


MATLAB Information Types

Matrix

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

                      >>            a = [ 1 2 3 ; 4 5 six ; 7 viii 9]                          a =     1   2   3    iv   5   6    vii   8   9                  

When n is one the matrix is a row vector:

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

When one thousand is i the matrix is a column vector:

                      >>            c = [1; 2; 3]            c =    one   2   3                  

and when both n and m are 1 the one x ane matrix corresponds to a scalar.

                      >>            d = [1]            d =    1                  

MATLAB uses graphics objects to create visual representations of data. Arrays of numbers tin can exist used not only to shop scalar and vector information merely also the coordinate data of graphics objects. For example a two-dimensional array of numbers could be used to represent a surface by constructing a filigree of rectangles whose vertices are defined by using the row and column indices of each element as the 10– 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 three-dimensional grids. These data sets are characterized by multidimensional arrays of scalar or vector information and are typically defined on lattice structures representing values sampled in 3-D space.
MATLAB has two bones types of book data:

  • Scalar volume information
  • single values for each point
  • examples: temperature, pressure, density, elevation
  • Vector volume information
  • 2 or 3 values for each indicate, defining the components of a vector
  • magnitude and direction
  • examples: velocity, momentum

As an example of scalar volume data, nosotros will be using the the period M-file (G-files are text files containing MATLAB code). The flow dataset represents the speed profile of a submerged jet inside an space tank.

                      >>            [x,y,z,five] =            catamenia;        

The flow dataset contains 4 3-D arrays: 10, y, and z are coordinate arrays which specify the coordinates of each indicate in the volume and v specifies the scalar value for each bespeak in the volume.
Every bit an example of vector volume information, we will be using the wind dataset. The current of air dataset represents air currents over Northward America and is stored every bit a binary file. The load function imports variables containing numeric information from binary files or text files to the workspace.

                      >>            load            air current        

The wind dataset contains six 3-D arrays: x, y, and z are coordinate arrays which specify the coordinates of each point in the book and u, five, and w are the vector components for each point in the book.
Both the catamenia and wind datasets are role of the case data included in the MATLAB installation.


Modeling Visualization Algorithms

Modeling algorithms are often used to reveal internal details of a data fix in order to find where interesting regions exist.

Matrix to Surface
In MATLAB a surface is defined past the z-coordinates of points above a rectangular grid in the xy plane. The surface is formed past joining side by side points with straight lines. Surface plots are useful for visualizing large matrices and for graphing functions of two variables. In MATLAB there are two different 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 pinnacle of a surface over an underlying (i,j) filigree.
Surface backdrop provide boosted control over the visual advent of the surface. You can specify line styles, face coloring, lighting characteristics, etc.
The meshgrid function generates X and Y arrays for iii-D plots.
The peaks role is a part of two variables, obtained past translating and scaling Gaussian distributions.

          [X,Y] =            meshgrid(-three:0.25:3); Z =            peaks(Ten,Y);            figure;                          mesh(X,Y,Z);            view(three);            centrality([-3 iii -3 three -ten 10]);            grid            on;        

mesh

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

surface

Slicing
Slicing entails creating a "cross-department" of the dataset. Any kind of surface can be used to slice the volume, just the simplest technique is to use a plane to define the cutting surface thereby creating a planar cut. The color at each bespeak is determined past iii-D interpolation into the volume. The cutting surface interpolates the data as information technology cuts in order to colour the surface with values in the volume information where the piece is positioned. To create a planar cut we will use the slice part to do the bodily cutting.

          [x,y,z,v] =            flow;            figure;            xslice = five; yslice = 0; zslice = 0;              slice(10,y,z,v,xslice,yslice,zslice);            view(iii);            axis            on;            grid            on;            light;            lighting            phong;            camlight('left');            shading            interp;        

slice


Scalar Visualization Algorithms

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

Color Mapping
Color can be quite effective at conveying data values, both abiding and varying. Color mapping is a visualization technique in which each scalar value in the information set is mapped through a lookup table to a specific color. The scalar values are used every bit an index into the colour lookup table. In MATLAB the colour lookup table is called the colormap. Each MATLAB figure window has a colormap associated with it. The colormap is a iii-column ii-D matrix whose length is equal to the number of colors that are defined. Each row of the matrix defines a single color by specifying 3 values in the range of zip to i. These values define the RGB components (i.eastward., the intensities of the reddish, light-green, and bluish video components) of each color.
The chief MATLAB office used for color mapping is colormap. Colormaps can be created with either MATLAB array operations or with ane of the several color tabular array generating functions (jet, hsv, hot, cool, summer, and gray). Each of the colour table generating functions has an optional parameter that specifies the number of colors or rows in the resulting colormap. The colorbar function displays the current colour scalar mapping, either vertically or horizontally, in the effigy window. Here is example code which shows the mapping of the entire scalar range of the data into the jet color table:

          [ten,y,z,v] =            menses;            effigy; xslice = 5; yslice = 0; zslice = 0;            piece(x,y,z,v,xslice,yslice,zslice);            view(3);            axis([0 10 -4 4 -three 3]);            filigree            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, nosotros wish to map the lower values to reds and higher values to dejection we can employ the flipud function. Hither is instance code which shows the technique:

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

colormap2

And if instead of mapping the entire scalar range of the data into the colour table, we wish to set 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 function enables us to emphasize a particular range of interest in the data. Here is example code which shows the result of limiting the color range from -5.0 to 2.0 and then that any scalar value lower than -v.0 are mapped to the same color as -5.0 and any scalar value greater than two.0 are mapped to the same color as two.0:

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

colormap3

If you want fifty-fifty more than control over the color mapping, you lot can use the colormap editor. Y'all open the colormap editor past selecting Colormap from the Edit menu of the figure whose colormap y'all wish to modify.

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, M, and B values changes. Yous can select and movement the node pointers to change the range of colors in the colormap. The color of a node arrow remains constant as you move it, but the colormap changes by linearly interpolating the RGB values betwixt nodes. You lot can likewise add a node pointer past clicking below the respective prison 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 i constructs a boundary betwixt distinct regions in the information. 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 offset stride in contouring is to explore the data infinite to find points nearly a contour or region of interest. Once found these points are and so connected into either contour lines (isolines) for two-dimensional data or into surfaces (isosurfaces) for iii-dimensional data. The lines or surfaces tin can also be colour mapped using the scalar data. The primary MATLAB functions used for creating contour lines are contour and contour3 and contourslice.
profile(X,Y,Z,v) draws a contour plot of matrix Z with contour lines at the information values specified in the vector v.
contour3(Ten,Y,Z,v) draws a contour plot of matrix Z in a three-D view using X and Y to determine the x- and y-axis limits.
contourslice(X,Y,Z,V,Sx,Sy,Sz,five) draws contour plots in the x-, y-, and z-axis aligned planes at the points in the vectors Sx, Sy, Sz.

Hither are some examples which shows how to generate contours for ii-dimensional data:

          [X,Y] =            meshgrid(-3:0.25:3); Z =            peaks(X,Y);            figure;            isovalues = (-iii.0:0.5:3.0);              profile(X,Y,Z,isovalues);            view(2);            centrality            on;            grid            on;        

contour1

          [Ten,Y] =            meshgrid(-3:0.25:3); Z =            peaks(X,Y);            figure;            isovalues = (-3.0:0.5:three.0);              contour3(Ten,Y,Z,isovalues);            view(3);            axis            on;            grid            on;        

contour2

          [x,y,z,five] =            catamenia;            figure;            xslice = (1:3:9); yslice = 0; zslice = 0; isovalues = (-3.0:0.25:three.0);              contourslice(x,y,z,5,xslice,yslice,zslice,isovalues);            view([-x xl]);            centrality            on;            grid            on;        

contour3

For three-dimensional data we can generate an isosurface. Through exploration of the volume data, nosotros tin can make up one's mind isovalues that reveal useful information about the data. To offset 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(X,Y,Z,Five,isovalue) computes isosurface data from the volume data V at the isosurface value specified in isovalue. The isosurface function connects points that have the specified value the same fashion contour lines connect points of equal height.
isosurface(Ten,Y,Z,V,isovalue,colors) computes isosurface data and also interpolates the assortment colors onto the scalar field and colors the isosurface appropriately.
isonormals(X,Y,Z,Five,vertices) computes the normals of the isosurface vertices from the vertex list necessary for lighting.
patch is the low-level graphics function that creates patch graphics objects. A patch object is one or more polygons divers past the coordinates of its vertices.

In this case we show how to create a single colored isosurface:

          [x,y,z,five] =            menstruum;            isovalue = -i; purple = [1.0 0.v 1.0];            figure;            p =              patch(isosurface(x,y,z,v,isovalue));              isonormals(x,y,z,v,p);              set(p,'FaceColor',purple,'EdgeColor','none');            view([-10 40]);            axis            on;            grid            on;            low-cal;            lighting            phong;            camlight('left');        

isosurface1

In this side by side case we create two isosurfaces and color each of them by using the v scalar data of the flow dataset and the current colormap. The fcolors variable is a vector containing scalar values for each of the vertices in the isosurface.

                      [x,y,z,v] =            menstruum;            isovalue = -one; colors = v;            effigy;            [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(10,y,z,v,p2);            view([-ten forty]);            centrality            on;            grid            on;            colormap(jet(64));            light;            lighting            phong;            camlight('left');        

isosurface2


Vector Visualization Algorithms

Vector data is a three-dimensional representation of management and magnitude associated with each betoken in the dataset. Vector data is often used to describe charge per unit of change of some quantity. Vectors can also be used to describe fluid menstruum. There are several algorithms that tin be used to visualize vector data.

Oriented Glyphs
I visualization technique for vector data is to draw an oriented, scaled glyph for each vector. The orientation and calibration of the glyph can signal the direction and magnitude of the vector. The glyph may also exist colored co-ordinate to vector magnitude or some other scalar quantity (e.g. temperature or pressure). Glyphs are polygonal objects such as a cone or an arrow. In MATLAB there are currently two types of glyph available: the cone or the arrow. The primary MATLAB part for creating oriented glyph visualizations is coneplot.
coneplot(X,Y,Z,U,5,W,Cx,Cy,Cz) plots vectors as cones pointing in the direction of the vector, having a length proportional to the magnitude of the vector.
X, 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(...,southward) automatically scales the cones to fit the graph and so stretches them by the scale factors. If y'all do not specify a value for due south, a value of 1 is used. Apply s = 0 to plot the cones without automatic scaling.
coneplot(...,color) interpolates the assortment colour onto the vector field and then colors the cones according to the interpolated values. The size of the color array must be the same size as the U, 5, Westward arrays. This choice only works with cones.
coneplot(...,'quiver') draws arrows instead of cones.

This instance uses arrow glyphs to visualize the vector information. 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(10(:)); ymin = min(y(:)); ymax = max(y(:)); zmin = min(z(:)); zmax = max(z(:)); scale = iv;            effigy;            [cx cy cz] =              meshgrid(xmin:5:xmax,ymin:5:ymax,zmin:2:zmax);              coneplot(x,y,z,u,v,w,cx,cy,cz,calibration,'quiver');            view([-35 60]);            camproj            perspective;            camzoom(iii.0);            axis            on;            filigree            off;            box            on;        

glyph1

This case uses cone glyphs to visualize the vector information. The cones are colored past wind speed.

                      load            wind; xmin =            min(x(:)); xmax =            max(x(:)); ymin =            min(y(:)); ymax =            max(y(:)); zmin =            min(z(:)); zmax =            max(z(:)); wind_speed =            sqrt(u.^2 + v.^two + west.^2); colors = wind_speed; scale = 4;            figure;            [cx cy cz] =              meshgrid(xmin:five:xmax,ymin:five:ymax,zmin:2:zmax); c =              coneplot(x,y,z,u,v,west,cx,cy,cz,calibration,colors);              set(c,'EdgeColor','none');            view([-35 60]);            camproj            perspective;            camzoom(iii.0);            axis            on;            grid            off;            box            on;            calorie-free;            lighting            flat;        

glyph2

Streamlines
A streamline can exist thought of as the path a massless particle takes flowing through a velocity field (i.e. vector field). Streamlines tin be used to convey the construction of a vector field by providing a snapshot of the menstruation 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,Five,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(Ten,Y,Z,U,V,W,startx,starty,startz) draws stream tubes from the vector volume data.
X, Y, Z define the coordinates for the vector field
U, V, W define the vector field
startx, starty, startz define the starting positions of the streams
Come across 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            air current; xmin =            min(x(:)); xmax =            max(x(:)); ymin =            min(y(:)); ymax =            max(y(:)); zmin =            min(z(:)); zmax =            max(z(:)); purple = [i.0 0.5 1.0];            figure;            [sx sy sz] =              meshgrid(xmin,ymin:ten:ymax,zmin:2:zmax); h =              streamline(x,y,z,u,5,westward,sx,sy,sz);              set(h,'LineWidth',i,'Color',regal);            view([-40 50]);            axis            on;            grid            off;            box            on;        

stream1

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

                      load            current of air; xmin =            min(x(:)); xmax =            max(10(:)); ymin =            min(y(:)); ymax =            max(y(:)); zmin =            min(z(:)); zmax =            max(z(:));            figure;            [sx sy sz] =              meshgrid(xmin,ymin:10:ymax,zmin:two:zmax) h =              streamribbon(x,y,z,u,v,westward,sx,sy,sz);              fix(h,'EdgeColor','none');            view([-40 50]);            axis            on;            grid            off;            box            on;            light;            lighting            flat;            camlight('left');        

stream2

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

                      load            wind; xmin =            min(10(:)); xmax =            max(x(:)); ymin =            min(y(:)); ymax =            max(y(:)); zmin =            min(z(:)); zmax =            max(z(:));            figure;            [sx sy sz] =              meshgrid(xmin,ymin:ten:ymax,zmin:2:zmax); h =              streamtube(ten,y,z,u,v,westward,sx,sy,sz);              set(h,'EdgeColor','none');            view([-forty 50]);            axis            on;            grid            off;            box            on;            calorie-free;            lighting            apartment;            camlight('left');        

stream3


Boosted Help

For an introductory tutorial on using MATLAB, see the SCV tutorial an Introduction to MATLAB.
MathWorks, the developer of MATLAB, has all-encompassing MATLAB Technical Documentation and Back up including user guides, video tutorials, and demos on its website.
There is a total gear up of documentation available from within MATLAB itself which tin can exist viewed past selecting Product Help from the Help menu.
For specifics on running MATLAB on SCV systems, come across our MATLAB Assist Page.
For more than information on MATLAB, visit the MATLAB website or the MATLAB Wiki.
There are also several other MATLAB tutorials bachelor on the spider web: MATLAB Tutorials.


References

All of the information 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 corporeality of information you lot need to sympathise in order to commencement visualizing your information.
Getting Started with MATLAB, version 7, The MathWorks, Inc.

Using MATLAB, version 7, The MathWorks, Inc.

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

MathWorks: MATLAB Technical Documentation and Support