How to plot a figure like this in matlab plot 标注?

Axis Limits in MATLAB | eHow
MATLAB is an industry standard software package for the analysis and presentation of display-quality scientific and technical data. When preparing data graphs for presentation, you must provide an appropriate range on all graph axes. It's also critical that the ranges of graphs are comparable between related figures. MATLAB provides a variety of mechanisms for manipulating axis bounds programmatically and through the user interface.
MATLAB displays graphs in a data object, known as a figure, that has one or more sets of axes associated with it. Each set of axes can have two or three individual axis objects, depending on the dimensionality of the data. Each axis has a lower and upper bound, spacing of tick marks and other cosmetic properties.
You access the figure axis object in MATLAB in one of two ways. Accessing the user interface for the axis properties requires clicking on the &Edit& menu button below the figure title bar and selecting the &Axes Properties ...& option. You also can change figure axes programmatically, using the axis() and other MATLAB commands:
axis square
axis tight
To get a handle to the currently selected, or last updated, axis object, use the gca() command, short for get current axis.
By default, MATLAB sets the axis limits to auto-scale to the current data. You can simultaneously set the bounds for x and y -- and so forth for z and other dimensions -- with the axis() command:
axis([xmin xmax ymin ymax])
The individual limits for x and y can be set via the xlim() and ylim() commands. The axis mode you set using the axis() command also can be achieved using the xlim() and ylim() commands:
xlim([xmin xmax])
xlim('off'')
With the subplot() command, you can display multiple graphs inside the same figure window. It's often necessary for the axis bounds to be identical for subplots, even if the bounds of the data differ. You can synchronize multiple axes by saving the axis handles and using the linkaxes() command:
my_axes(1) = subplot(2,2,1);
my_axes(2) = subplot(2,2,2);
linkaxes(my_axes);About Mathuranathan
- Founder and Author @
which has garnered worldwide readership. He is a masters in communication engineering and
has 7 years of technical expertise in channel modeling and has worked in various technologies ranging from read channel design for hard drives, GSM/EDGE/GPRS, OFDM, MIMO, 3GPP PHY layer and DSL.
He also specializes in tutoring on various subjects like signal processing, random process, digital communication etc..,
Pingback: ()
Ebook referred by many around the world
Participate
Follow Us!
- 64 votes
- 21 votes
- 18 votes
- 11 votes
- 10 votes
Recent Posts
On the Forums
Subscribe to Gaussianwaves via Email
Enter your email address to subscribe to this Website and receive notifications of new articles by email.
Join 167 other subscribers
Email Address
Send to Email Address
Your Email Address
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.Using MATLAB to Visualize Scientific Data (online tutorial) :
TechWeb : Boston University
Using MATLAB to Visualize Scientific Data (online tutorial)
Table of Contents
A brief introduction.
A few basic hints that will help you get started.
Introduction
MATLAB is a high-performance language for technical computing. It integrates computation, visualization, and programming in an easy-to-use environment where problems and solutions are expressed in common mathematical notation. MATLAB is an interactive system whose basic data type is the array or matrix.
MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as annotating and printing these graphs. It includes high-level functions for two-dimensional and three-dimensional data visualization, image processing, animation, and presentation graphics. There are two basic ways to create graphs in MATLAB. You can either use the MATLAB GUI plotting tools to interactively create graphs (see
for more information) or you can use 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. We will cover major visualization techniques such as slicing, color mapping, contouring, oriented glyphs, and streamlines. It is assumed that the student is familiar with the basics of using MATLAB.
For an introductory tutorial on using MATLAB, see the SCV tutorial an . , the developer of MATLAB, also has extensive
including video tutorials on its website. And there is a full set of documentation available from within MATLAB itself which can be viewed by selecting Product Help from the Help menu.
Getting started
The most effective way for you to go through this tutorial is to run the listed example 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 be helpful for you to browse the MATLAB documentation for the specific functions as we discuss them (links are provided). After browsing the documentation, you should then experiment with the example code by varying some of the arguments and watching the effect this has on the output. By playing with the example code, you will gain a deeper understanding of how the various graphic functions work.
Boston University SCV users, please go to the
for information specific to the installation at this site. This will tell you on what machines MATLAB is available, how to set 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 independent graphics layer. In MATLAB graphics objects are used to create visual representations of data. There are two basic 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 (2D matrix representation of an image), light 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 need a graphics window which contains a figure, an axes, and a view.
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 can contain menus, toolbars, user-interface objects, context menus, axes, or any other type of graphics object. MATLAB functions that generate graphics output such as plot, surf, slice, etc. will create a figure if none already exists. If a figure does exist, then these functions will display their graphics output in the current figure window (the last figure window used or clicked in). By default this will be done without clearing or resetting the current figure properties.
To create a new figure, use the
function. Here is example code to create a simple graphics window:
Every graphics object has a set of properties associated with it. These properties define the different attributes of an object, such as its color, size, position, etc. Properties are usually specified by name/property pairs e.g. figure( 'PropertyName', propertyvalue, ... ). These properties can be set either at the time of creation by specifying property name and property value pairs or after the graphics object has been created by using the
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. Any property not specified as an argument will use the default values. See the
for a list of properties that can be set 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, bottom 500, width 250, height 250]:
figure('Name','Test Window','Position',[100 500 350 350],'MenuBar','none')
You can use
(clear figure) to clear the contents of the current figure and reset all of its properties to their default values.
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 you 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 one does not already exist.
As with figure properties, axes properties are used to specify the characteristics of the axes. The
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, camera target, up vector, and view angle can all be directly set with axes properties. The
function, however, is a low-level function. Though you can specify values for these properties directly, it is much easier to use the view function (covered in the next section) to set up the axes using default property values and to define a reasonable view.
The view is the particular orientation you set to display 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 two basic areas:
Positioning the viewpoint to orient the scene
Setting the aspect ratio and relative axis scaling to control the shape of the objects being displayed
Positioning the viewpoint: The
function specifies the viewpoint by defining azimuth and elevation 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. Elevation is the angle above (positive angle) or below (negative angle) the x-y plane.
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 elevation = 90°.
For 3-D plots, the default is azimuth = -37.5° and elevation = 30°.
view(2) sets the default two-dimensional view, with az = 0, el = 90.
view(3) sets the default three-dimensional view, with az = –37.5, 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-axis as 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 correspond to mov negative values correspond to moving below the object.
Here is example code that creates a simple graphics window with a default axes, a view, and a surface:
Z = peaks(20);
h = surf(Z);
view([-20,25]);
Setting the aspect ratio and axis scale: The
command enables you to adjust the aspect ratio of graphs. The axis command also enables you to adjust the scaling of graphs. Normally MATLAB stretches the axes to fill 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 you should use the vis3d option.
axis([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 3-D objects and overrides stretch-to-fill.
Here is the same code but with a different axes:
Z = peaks(20);
h = surf(Z);
view([-20,25]);
axis([0 30 0 30 -15 15]);
The , , and
commands add x-, y-, and z-axis labels. The
command adds a title at the top of the figure and the
function inserts text anywhere in the figure.
Here is example code that creates a simple graphics window with a default axes, a default view, a surface, and labels:
Z = peaks(20);
h = surf(Z);
xlabel('Longitude');
ylabel('Latitude');
zlabel('Altitude');
title('Surface of Peaks');
The Camera Toolbar
Once you have established the initial view for your visualization, you can then use the Camera toolbar to interactively control the camera. To enable the Camera toolbar, select Camera Toolbar from the figure window’s View menu. Your figure window should now look like this:
This camera toolbar contains the following parts:
for information on how to use the camera toolbar.
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 to position light sources and adjust the characteristics of lit objects. These commands include the following:
– Creates a light object
– Selects a lighting method
– Sets the reflectance properties of lit objects
– Creates or moves a light with respect to the camera position
– 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);
h = surf(Z);
camlight('left');
MATLAB Data Types
The fundamental data type of MATLAB is the matrix or array. A matrix is an n row by m column array of numbers or objects corresponding to numbers:
&& a = [ 1 2 3 ; 4 5 6 ; 7 8 9]
1 2 3 4 5 6 7 8 9
When n is 1 the matrix is a row vector:
&& b = [1 2 3]
When m is 1 the matrix is a column vector:
&& c = [1; 2; 3]
and when both n and m are 1 the 1 x 1 matrix corresponds to a scalar.
&& d = [1]
MATLAB uses graphics objects to create visual representations of data. Arrays of numbers can be used not only to store scalar and vector data but 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 grid of rectangles whose vertices are defined by using the row and column indices of each element as 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 three-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 two basic types of volume data:
Scalar volume data
single values for each point
examples: temperature, pressure, density, elevation
Vector volume data
two or three values for each point, 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 M-file (M-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 four 3-D arrays: x, y, and z are coordinate arrays which specify the coordinates of each point in the volume and v specifies the scalar value for each point in the volume.
As 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 as a binary file. The
function imports variables containing numeric data from binary files or text files to the workspace.
&& load wind
The wind dataset contains six 3-D arrays: x, y, and z are coordinate arrays which specify the coordinates of each point in the volume and u, v, and w are the vector components for each point in the volume.
Both the flow and wind 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 data set 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 x-y plane. The surface is formed by 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 two different types of surface plots: mesh plots and surface plots. Mesh plots are colored wire-frame surfaces. Surface plots are colored faceted surfaces.
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.
provide additional control over the visual appearance of the surface. You can specify line styles, face coloring, lighting characteristics, etc.
function generates X and Y arrays for 3-D plots.
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);
mesh(X,Y,Z);
axis([-3 3 -3 3 -10 10]);
[X,Y] = meshgrid(-3:0.25:3);
Z = peaks(X,Y);
surf(X,Y,Z);
axis([-3 3 -3 3 -10 10]);
camlight('left');
Slicing entails creating a “cross-section” of the dataset. Any kind of surface can be used to slice the volume, but the simplest technique is to use a plane to define the cutting surface thereby creating a planar cut. The color at each point is determined by 3-D interpolation into the volume. The cutting surface interpolates the data as 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 will use the
function to do the actual cutting.
[x,y,z,v] = flow;
xslice = 5;
yslice = 0;
zslice = 0;
slice(x,y,z,v,xslice,yslice,zslice);
camlight('left');
Scalar Visualization Algorithms
Scalars are single data 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
Color can be quite effective at conveying data values, both constant 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 index 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 defined. Each row of the matrix defines a single color by specifying three values in the range of zero to one. These values define the RGB components (i.e., the intensities of the red, green, and blue video components) of each color.
The primary MATLAB function used for color mapping is . Colormaps can be created with either MATLAB array operations or with one of the several color table generating functions (jet, hsv, hot, cool, summer, and gray). Each of the color table generating functions has an optional parameter that specifies the number of colors or rows in the resulting colormap. The
function displays the current color scalar mapping, either vertically or horizontally, in the figure window. Here is example code which shows the mapping of the entire scalar range of the data into the jet color table:
[x,y,z,v] = flow;
xslice = 5;
yslice = 0;
zslice = 0;
slice(x,y,z,v,xslice,yslice,zslice);
axis([0 10 -4 4 -3 3]);
colormap(jet(64));
colorbar('vertical');
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
function. Here is example code which shows the technique:
[x,y,z,v] = flow;
xslice = 5;
yslice = 0;
zslice = 0;
slice(x,y,z,v,xslice,yslice,zslice);
axis([0 10 -4 4 -3 3]);
colormap(flipud(jet(64)));
colorbar('vertical');
And if instead of mapping the entire scalar range of the data into the color 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
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 so that any scalar value lower than -5.0 are mapped to the same color as -5.0 and any scalar value greater than 2.0 are mapped to the same color as 2.0:
[x,y,z,v] = flow;
xslice = 5;
yslice = 0;
zslice = 0;
slice(x,y,z,v,xslice,yslice,zslice);
axis([0 10 -4 4 -3 3]);
colormap(flipud(jet(64)));
caxis([-5.0,2.0]);
colorbar('vertical');
If you want even more control over the color mapping, you can use the . You open the colormap editor by selecting Colormap from the Edit menu of the figure whose colormap you wish to modify.
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 move it, but the colormap changes by linearly interpolating the RGB values between nodes. You can also add a node pointer by clicking below the corresponding cell in the colormap strip.
Here is an example of using the color map editor:
Contours / Isosurfaces
Contouring is a technique where one constructs a boundary between distinct regions in the data. Contours are lines or surfaces of constant scalar value. This is a natural extension from color mapping as our eyes instinctively separate similarly colored areas into distinct regions. The first step 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 contour lines (isolines) for two-dimensional data or into surfaces (isosurfaces) for three-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(X,Y,Z,v) draws a contour plot of matrix Z with contour 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 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(X,Y);
isovalues = (-3.0:0.5:3.0);
contour(X,Y,Z,isovalues);
[X,Y] = meshgrid(-3:0.25:3);
Z = peaks(X,Y);
isovalues = (-3.0:0.5:3.0);
contour3(X,Y,Z,isovalues);
[x,y,z,v] = flow;
xslice = (1:3:9);
yslice = 0;
zslice = 0;
isovalues = (-3.0:0.25:3.0);
contourslice(x,y,z,v,xslice,yslice,zslice,isovalues);
view([-10 40]);
For three-dimensional data we can generate an isosurface. Through exploration of the volume data, we can determine isovalues that reveal useful information about the data. To start select an isovalue within the range of values in the volume data. The primary MATLAB functions used for creating isosurfaces are , , and .
isosurface(X,Y,Z,V,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 way contour lines connect points of equal elevation.
isosurface(X,Y,Z,V,isovalue,colors) computes isosurface data 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 low-level graphics function that creates patch graphics objects. A patch object is one or more polygons defined by the coordinates of its vertices.
In this example we show how to create a single colored isosurface:
[x,y,z,v] = flow;
isovalue = -1;
purple = [1.0 0.5 1.0];
p = patch(isosurface(x,y,z,v,isovalue));
isonormals(x,y,z,v,p);
set(p,'FaceColor',purple,'EdgeColor','none');
view([-10 40]);
camlight('left');
In this next example 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] = flow;
isovalue = -1;
[faces,verts,fcolors] = isosurface(x,y,z,v,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,v,isovalue2,colors);
p2 = patch('Vertices',verts,'Faces',faces,'FaceVertexCData',fcolors, ...
'FaceColor','interp','EdgeColor','none');
isonormals(x,y,z,v,p2);
view([-10 40]);
colormap(jet(64));
camlight('left');
Vector Visualization Algorithms
Vector data is a three-dimensional representation of direction and magnitude associated with each point in the dataset. Vector data is often used to describe rate of change of some quantity. Vectors can also be used to describe fluid flow. There are several algorithms that can be used to visualize vector data.
Oriented Glyphs
One visualization technique for vector data is to draw an oriented, scaled glyph for each vector. The orientation and scale of the glyph can indicate the direction and magnitude of the vector. The glyph may also be colored according 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 function for creating oriented glyph visualizations is .
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 define the vector field
Cx, Cy, Cz define the location of the cones in the vector field
for tips on how to select starting locations.
coneplot(...,s) automatically scales the cones to fit the graph and then stretches them by the scale factors. If you do not 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 according to the interpolated values. The size of the color array must be the same size as the U, V, W arrays. This option only 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 entire volume.
xmin = min(x(:));
xmax = max(x(:));
ymin = min(y(:));
ymax = max(y(:));
zmin = min(z(:));
zmax = max(z(:));
scale = 4;
[cx cy cz] = meshgrid(xmin:5:xmax,ymin:5:ymax,zmin:2:zmax);
coneplot(x,y,z,u,v,w,cx,cy,cz,scale,'quiver');
view([-35 60]);
camzoom(3.0);
This example uses cone glyphs to visualize the vector data. The cones are colored by wind speed.
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_
scale = 4;
[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 60]);
camzoom(3.0);
Streamlines
A streamline can be thought of as the path a massless particle takes flowing through a velocity field (i.e. vector field). Streamlines can be used to convey the structure of a vector field by providing a snapshot of the flow 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 , , and .
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, W define the vector field
startx, starty, startz define the starting positions of the streams
for tips on how to select starting locations.
This example uses stream lines to visualize the vector data.
xmin = min(x(:));
xmax = max(x(:));
ymin = min(y(:));
ymax = max(y(:));
zmin = min(z(:));
zmax = max(z(:));
purple = [1.0 0.5 1.0];
[sx sy sz] = meshgrid(xmin,ymin:10:ymax,zmin:2:zmax);
h = streamline(x,y,z,u,v,w,sx,sy,sz);
set(h,'LineWidth',1,'Color',purple);
view([-40 50]);
This example uses stream ribbons to visualize the vector data. The ribbons are colored by the magnitude of the vectors.
xmin = min(x(:));
xmax = max(x(:));
ymin = min(y(:));
ymax = max(y(:));
zmin = min(z(:));
zmax = max(z(:));
[sx sy sz] = meshgrid(xmin,ymin:10:ymax,zmin:2:zmax)
h = streamribbon(x,y,z,u,v,w,sx,sy,sz);
set(h,'EdgeColor','none');
view([-40 50]);
camlight('left');
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.
xmin = min(x(:));
xmax = max(x(:));
ymin = min(y(:));
ymax = max(y(:));
zmin = min(z(:));
zmax = max(z(:));
[sx sy sz] = meshgrid(xmin,ymin:10:ymax,zmin:2:zmax);
h = streamtube(x,y,z,u,v,w,sx,sy,sz);
set(h,'EdgeColor','none');
view([-40 50]);
camlight('left');
Additional Help
For an introductory tutorial on using MATLAB, see the SCV tutorial an .
, the developer of MATLAB, has extensive
including user guides, video tutorials, and demos on its website.
There is a full set of documentation available from within MATLAB itself which can be viewed by selecting Product Help from the Help menu.
For specifics on running MATLAB on SCV systems, see our .
For more information on MATLAB, visit the
There are also several other MATLAB tutorials available on the web: .
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 need to understand in order to start 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 plot 标注 的文章

 

随机推荐