Table of Contents

Introduction
A cursory introduction.
Getting started
A few basic hints that will help you get started.
Graphics Model
Creating a Graphics Window
The Photographic 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 Aid
References

Introduction

MATLAB is a high-performance linguistic communication for technical computing. Information technology integrates ciphering, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in mutual mathematical note. MATLAB is an interactive system whose basic data blazon is the array or matrix.

MATLAB has extensive facilities for displaying vectors and matrices every bit graphs, as well as annotating and printing these graphs. It includes high-level functions for ii-dimensional and three-dimensional data visualization, prototype processing, animation, and presentation graphics. There are ii bones means to create graphs in MATLAB. You can either use the MATLAB GUI plotting tools to interactively create graphs (see Some Means to Use Plotting Tools for more than information) or you can apply the command interface by entering MATLAB graphics commands in the Command Window.

In this tutorial we will use the command interface to show how to visualize scientific data using MATLAB graphics commands. Nosotros volition encompass major visualization techniques such equally slicing, colour mapping, contouring, oriented glyphs, and streamlines. It is causeless that the student is familiar with the basics 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 full ready of documentation available from within MATLAB itself which tin can be viewed by selecting Product Aid from the Assistance menu.


Getting started

The almost effective style for you to go through this tutorial is to run the listed example code in a MATLAB session as you keep through the tutorial. This can be accomplished by copying and pasting the listed instance code into the MATLAB Control Window. Information technology will also be helpful for you lot to browse the MATLAB documentation for the specific functions as we discuss them (links are provided). Subsequently browsing the documentation, you should so experiment with the example code past varying some of the arguments and watching the result this has on the output. By playing with the example code, you lot will gain a deeper understanding of how the diverse graphic functions work.

Boston University SCV users, please go to the SCV MATLAB Help Page for data specific to the installation at this site. This will tell you on what machines MATLAB is available, how to set up your environs, how to set your display, and where the documentation is.


Graphics Model

MATLAB has an abstract graphics layer in a higher place 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 data. There are two 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 (2nd matrix representation of an image), light sources, and axes (ascertain the coordinate system). Composite graphics objects are composed of cadre graphics objects that have been grouped together to provide a more convenient interface.

Creating a Graphics Window

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

Effigy

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

To create a new effigy, use the figure part. Here is example code to create a elementary graphics window:

                      figure                  

figure1

Every graphics object has a fix of backdrop associated with it. These properties define the different attributes of an object, such as its color, size, position, etc. Properties are usually specified by proper noun/property pairs e.g. figure( 'PropertyName', propertyvalue, ... ). These properties tin be set either at the time of creation past specifying belongings proper noun and holding value pairs or afterwards the graphics object has been created by using the set function.

When creating a new figure, MATLAB creates a window whose characteristics are specified past your estimator's windowing system, past the default MATLAB effigy properties, and past the properties specified as arguments to the role. Whatsoever holding not specified as an argument will use the default values. Run across the Figure Backdrop for a list of properties that can be gear up for a figure.

Here is an example of setting figure properties 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('Proper noun','Examination Window','Position',[100 500 350 350],'MenuBar','none')        

figure2

You can utilize clf (clear figure) to articulate the contents of the electric current effigy 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 calibration graphical output to produce the view of the data that you come across on screen. Past default, the size of the axes MATLAB creates is normalized to the size of the effigy window. All functions that depict graphics create an axes object if 1 does not already be.

As with figure properties, axes backdrop are used to specify the characteristics of the axes. The Axes Properties list all axes properties and provide an overview of the characteristics that are affected by each property. For example camera properties such as the camera position, photographic camera target, up vector, and view angle tin all be directly prepare with axes properties. The axes function, withal, is a low-level role. Though you can specify values for these backdrop directly, information technology is much easier to use the view function (covered in the next department) to fix the axes using default property values and to define a reasonable view.

View

The view is the item orientation you set to brandish the visualization. The term viewing refers to the process of displaying a graphical scene from various directions by adjusting the camera position, changing the perspective, changing the aspect ratio, etc.

MATLAB viewing is composed of 2 basic areas:

  • Positioning the viewpoint to orient the scene
  • Setting the aspect ratio and relative centrality scaling to command the shape of the objects beingness 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 ten-y airplane, with positive angles indicating counterclockwise rotation of the viewpoint. Elevation is the angle above (positive angle) or below (negative angle) the x-y aeroplane.

coordinates

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

  • For 2-D plots, the default is azimuth = 0° and elevation = 90°.
  • For 3-D plots, the default is azimuth = -37.5° and summit = 30°.

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

The azimuth, az, is the horizontal rotation most 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 in a higher place the object; negative values represent to moving beneath the object.

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

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

figur33

Setting the attribute ratio and axis scale: The axis command enables you lot to suit the attribute ratio of graphs. The axis control also enables you to adjust the scaling of graphs. Normally MATLAB stretches the axes to fill the window and chooses advisable axes ranges based on the maxima and minima of the plotted data. If yous will exist interactively rotating the visualization in the figure window y'all should use the vis3d choice.

centrality([xmin xmax ymin ymax zmin zmax]) sets the limits for the x-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 up.

Here is the same code but with a different axes:

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

figure4

Labels

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

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

          Z =            peaks(20);            effigy; h =            surf(Z);            view(3);            centrality            on;                          xlabel('Longitude');              ylabel('Latitude');              zlabel('Altitude');              title('Surface of Peaks');                  

figure5

The Camera Toolbar

Once you accept established the initial view for your visualization, you can then use the Photographic camera toolbar to interactively control the camera. To enable the Camera toolbar, select Camera Toolbar from the figure window's View card. Your figure window should now look like this:

figure6

This camera toolbar contains the following parts:

camera toolbar

Run into View Command with the Camera Toolbar for information on how to use the camera toolbar.

Lighting

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

light – Creates a light object

lighting – Selects a lighting method

material – Sets the reflectance properties of lit objects

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

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

Here is example lawmaking that creates a simple graphics window with a default axes, a default view, a surface, and a camera low-cal with phong shading:

          Z =            peaks(20);            figure; h =            surf(Z);            view(3);            axis            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 n row by m cavalcade array of numbers or objects corresponding to numbers:

                      >>            a = [ 1 2 3 ; iv 5 half dozen ; seven 8 9]                          a =     i   2   iii    4   5   6    vii   8   nine                  

When n is 1 the matrix is a row vector:

                      >>            b = [ane 2 3]            b =    one   2   3                  

When m is 1 the matrix is a column vector:

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

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

                      >>            d = [i]            d =    1                  

MATLAB uses graphics objects to create visual representations of data. Arrays of numbers tin can be used not only to store scalar and vector data but besides the coordinate information of graphics objects. For instance a 2-dimensional array of numbers could be used to represent a surface past amalgam a grid of rectangles whose vertices are defined by using the row and cavalcade indices of each element as the 10– and y-coordinates and the value of each element as the z-coordinate.

Volume Information
MATLAB uses the term "Volume Visualization" to refer to the graphical representation of information sets that are divers on three-dimensional grids. These information 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 data
  • unmarried values for each point
  • examples: temperature, pressure, density, pinnacle
  • Vector book information
  • two or three values for each signal, defining the components of a vector
  • magnitude and direction
  • examples: velocity, momentum

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

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

The flow dataset contains 4 three-D arrays: x, y, and z are coordinate arrays which specify the coordinates of each signal in the book and v specifies the scalar value for each point in the book.
Equally an example of vector volume data, we will be using the wind dataset. The wind dataset represents air currents over North 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            wind        

The wind dataset contains 6 iii-D arrays: x, y, and z are coordinate arrays which specify the coordinates of each point in the volume and u, v, and westward are the vector components for each bespeak in the volume.
Both the flow and air current datasets are part of the example information included in the MATLAB installation.


Modeling Visualization Algorithms

Modeling algorithms are frequently 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 divers by the z-coordinates of points above a rectangular grid in the teny airplane. The surface is formed by joining next 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 height of a surface over an underlying (i,j) grid.
Surface properties provide additional command over the visual advent of the surface. You tin can specify line styles, face up coloring, lighting characteristics, etc.
The meshgrid part generates Ten and Y arrays for 3-D plots.
The peaks office is a part of 2 variables, obtained by translating and scaling Gaussian distributions.

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

mesh

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

surface

Slicing
Slicing entails creating a "cantankerous-section" 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 colour at each indicate is determined past iii-D interpolation into the volume. The cutting surface interpolates the data every bit it cuts in order to color the surface with values in the book data where the slice is positioned. To create a planar cut nosotros will use the slice function to do the actual cutting.

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

slice


Scalar Visualization Algorithms

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

Color Mapping
Colour 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 data set is mapped through a lookup table to a specific color. The scalar values are used as an alphabetize into the color lookup table. In MATLAB the color lookup table is called the colormap. Each MATLAB figure window has a colormap associated with it. The colormap is a three-column 2-D matrix whose length is equal to the number of colors that are divers. Each row of the matrix defines a unmarried colour by specifying three values in the range of nix to 1. These values define the RGB components (i.due east., the intensities of the ruby-red, green, and blue video components) of each color.
The primary MATLAB role used for color mapping is colormap. Colormaps can be created with either MATLAB array operations or with one of the several colour table generating functions (jet, hsv, hot, absurd, summer, and grayness). Each of the color table generating functions has an optional parameter that specifies the number of colors or rows in the resulting colormap. The colorbar function displays the electric current color scalar mapping, either vertically or horizontally, in the figure window. Here is instance code which shows the mapping of the unabridged scalar range of the data into the jet color tabular array:

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

colormap

If instead of mapping the lower scalar values to blues and the higher values to reds, we wish to map the lower values to reds and higher values to blues we can use the flipud function. Here is instance code which shows the technique:

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

colormap2

And if instead of mapping the entire scalar range of the data into the color table, we wish to ready 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 u.s.a. to emphasize a detail range of interest in the data. Here is instance lawmaking which shows the result of limiting the color range from -v.0 to ii.0 so that any scalar value lower than -5.0 are mapped to the same colour every bit -5.0 and whatsoever scalar value greater than 2.0 are mapped to the same color as two.0:

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

colormap3

If you want fifty-fifty more control over the color mapping, you can utilise the colormap editor. You open the colormap editor past selecting Colormap from the Edit menu of the figure whose colormap you 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 indicate points in the colormap where the rate of the variation of R, G, and B values changes. You can select and move the node pointers to change the range of colors in the colormap. The color of a node pointer remains constant as you motility it, simply the colormap changes by linearly interpolating the RGB values betwixt nodes. You lot can as well add together a node pointer by clicking below 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 one constructs a purlieus betwixt singled-out regions in the data. Contours are lines or surfaces of abiding scalar value. This is a natural extension from color mapping as our eyes instinctively separate similarly colored areas into singled-out regions. The first footstep in contouring is to explore the data space to find points near a contour or region of interest. Once found these points are then connected into either profile lines (isolines) for two-dimensional information or into surfaces (isosurfaces) for 3-dimensional data. The lines or surfaces can also be color mapped using the scalar data. The primary MATLAB functions used for creating contour lines are contour and contour3 and contourslice.
profile(Ten,Y,Z,v) draws a contour plot of matrix Z with contour lines at the data values specified in the vector v.
contour3(Ten,Y,Z,five) draws a contour plot of matrix Z in a three-D view using 10 and Y to determine the ten- and y-axis limits.
contourslice(10,Y,Z,V,Sx,Sy,Sz,v) draws contour plots in the x-, 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:

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

contour1

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

contour2

          [10,y,z,v] =            flow;            figure;            xslice = (ane:3:nine); yslice = 0; zslice = 0; isovalues = (-3.0:0.25:3.0);              contourslice(x,y,z,five,xslice,yslice,zslice,isovalues);            view([-ten 40]);            axis            on;            grid            on;        

contour3

For iii-dimensional information we can generate an isosurface. Through exploration of the volume information, we can determine isovalues that reveal useful data most the information. To start select an isovalue within the range of values in the volume information. The primary MATLAB functions used for creating isosurfaces are isosurface, isonormals, and patch.
isosurface(X,Y,Z,5,isovalue) computes isosurface information from the book data V at the isosurface value specified in isovalue. The isosurface function connects points that take the specified value the aforementioned way contour lines connect points of equal elevation.
isosurface(X,Y,Z,V,isovalue,colors) computes isosurface data and as well interpolates the assortment colors onto the scalar field and colors the isosurface appropriately.
isonormals(10,Y,Z,V,vertices) computes the normals of the isosurface vertices from the vertex listing necessary for lighting.
patch is the low-level graphics function that creates patch graphics objects. A patch object is ane or more polygons defined by the coordinates of its vertices.

In this instance nosotros show how to create a single colored isosurface:

          [x,y,z,v] =            menstruation;            isovalue = -1; purple = [1.0 0.five 1.0];            figure;            p =              patch(isosurface(10,y,z,five,isovalue));              isonormals(ten,y,z,5,p);              fix(p,'FaceColor',majestic,'EdgeColor','none');            view([-ten forty]);            axis            on;            grid            on;            lite;            lighting            phong;            camlight('left');        

isosurface1

In this next example we create two isosurfaces and color each of them past using the v scalar data of the catamenia 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,5] =            flow;            isovalue = -1; colors = 5;            figure;            [faces,verts,fcolors] =              isosurface(x,y,z,5,isovalue,colors); p =              patch('Vertices',verts,'Faces',faces,'FaceVertexCData',fcolors, ... 'FaceColor','interp','EdgeColor','none');              isonormals(x,y,z,v,p); isovalue2 = 0; [faces,verts,fcolors] =              isosurface(x,y,z,5,isovalue2,colors); p2 =              patch('Vertices',verts,'Faces',faces,'FaceVertexCData',fcolors, ... 'FaceColor','interp','EdgeColor','none');              isonormals(10,y,z,v,p2);            view([-x forty]);            axis            on;            grid            on;            colormap(jet(64));            light;            lighting            phong;            camlight('left');        

isosurface2


Vector Visualization Algorithms

Vector data is a iii-dimensional representation of direction and magnitude associated with each point in the dataset. Vector information is ofttimes used to describe charge per unit of alter of some quantity. Vectors can too be used to describe fluid flow. There are several algorithms that tin be used to visualize vector data.

Oriented Glyphs
One visualization technique for vector information is to draw an oriented, scaled glyph for each vector. The orientation and scale of the glyph can betoken the direction and magnitude of the vector. The glyph may also exist colored according to vector magnitude or some other scalar quantity (e.g. temperature or force per unit area). Glyphs are polygonal objects such equally a cone or an pointer. In MATLAB there are currently two types of glyph available: the cone or the arrow. The primary MATLAB office for creating oriented glyph visualizations is coneplot.
coneplot(X,Y,Z,U,V,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 ascertain the vector field
Cx, Cy, Cz ascertain the location of the cones in the vector field
Come across 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 and so stretches them by the scale factors. If you do not specify a value for s, a value of 1 is used. Use south = 0 to plot the cones without automated scaling.
coneplot(...,color) interpolates the array color onto the vector field and and so colors the cones according to the interpolated values. The size of the colour assortment must be the aforementioned size as the U, V, W arrays. This selection but works with cones.
coneplot(...,'quiver') draws arrows instead of cones.

This example uses arrow glyphs to visualize the vector data. The arrows are scaled (proportional to the magnitude of the vectors) and are located over the unabridged volume.

                      load            current of air; xmin = min(x(:)); xmax = max(x(:)); ymin = min(y(:)); ymax = max(y(:)); zmin = min(z(:)); zmax = max(z(:)); calibration = four;            figure;            [cx cy cz] =              meshgrid(xmin:5:xmax,ymin:5:ymax,zmin:2:zmax);              coneplot(ten,y,z,u,five,w,cx,cy,cz,calibration,'quiver');            view([-35 60]);            camproj            perspective;            camzoom(3.0);            axis            on;            grid            off;            box            on;        

glyph1

This example uses cone glyphs to visualize the vector data. The cones are colored by wind speed.

                      load            air current; xmin =            min(ten(:)); xmax =            max(x(:)); ymin =            min(y(:)); ymax =            max(y(:)); zmin =            min(z(:)); zmax =            max(z(:)); wind_speed =            sqrt(u.^2 + 5.^2 + westward.^2); colors = wind_speed; scale = 4;            effigy;            [cx cy cz] =              meshgrid(xmin:5:xmax,ymin:5:ymax,zmin:2:zmax); c =              coneplot(x,y,z,u,v,w,cx,cy,cz,scale,colors);              set(c,'EdgeColor','none');            view([-35 sixty]);            camproj            perspective;            camzoom(iii.0);            centrality            on;            grid            off;            box            on;            light;            lighting            apartment;        

glyph2

Streamlines
A streamline can be thought of equally the path a massless particle takes flowing through a velocity field (i.e. vector field). Streamlines can exist used to convey the construction of a vector field past providing a snapshot of the flow at a given instant in time. Multiple streamlines tin 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,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, West define the vector field
startx, starty, startz define the starting positions of the streams
Run into 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 = [one.0 0.5 ane.0];            figure;            [sx sy sz] =              meshgrid(xmin,ymin:ten:ymax,zmin:2:zmax); h =              streamline(x,y,z,u,v,w,sx,sy,sz);              set(h,'LineWidth',1,'Color',imperial);            view([-forty 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            wind; xmin =            min(ten(:)); xmax =            max(x(:)); ymin =            min(y(:)); ymax =            max(y(:)); zmin =            min(z(:)); zmax =            max(z(:));            effigy;            [sx sy sz] =              meshgrid(xmin,ymin:10:ymax,zmin:2:zmax) h =              streamribbon(ten,y,z,u,v,westward,sx,sy,sz);              set(h,'EdgeColor','none');            view([-40 50]);            axis            on;            grid            off;            box            on;            lite;            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 divergence of the vector field.

                      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:ten:ymax,zmin:2:zmax); h =              streamtube(ten,y,z,u,five,w,sx,sy,sz);              gear up(h,'EdgeColor','none');            view([-xl fifty]);            axis            on;            filigree            off;            box            on;            light;            lighting            flat;            camlight('left');        

stream3


Additional Help

For an introductory tutorial on using MATLAB, run into 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.
In that location is a full set of documentation available from within MATLAB itself which tin can be viewed past selecting Product Assist from the Help menu.
For specifics on running MATLAB on SCV systems, see our MATLAB Assist Folio.
For more information on MATLAB, visit the MATLAB website or the MATLAB Wiki.
At that place are besides several other MATLAB tutorials available on the 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 amount of information you demand to understand in order to commencement visualizing your data.
Getting Started with MATLAB, version 7, The MathWorks, Inc.

Using MATLAB, version 7, The MathWorks, Inc.

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

MathWorks: MATLAB Technical Documentation and Support