Products & Services Industries Academia Support User Community Company

Learn more about MATLAB   

Example – Vector Field Displayed with Cone Plots

What Cone Plots Can Show

This example plots the velocity vector cones for the wind data. The graph produced employs a number of visualization techniques:

1. Create an Isosurface

Displaying an isosurface within the rectangular space of the data provides a visual context for the cone plot. Creating the isosurface requires a number of steps:

  1. Calculate the magnitude of the vector field, which represents the speed of the wind.

  2. Use isosurface and patch to draw an isosurface illustrating where in the rectangular space the wind speed is equal to a particular value. Regions inside the isosurface have higher wind speeds, regions outside the isosurface have lower wind speeds.

  3. Use isonormals to compute vertex normals of the isosurface from the volume data rather than calculate the normals from the triangles used to render the isosurface. These normals generally produce more accurate results.

  4. Set visual properties of the isosurface, making it red and without drawing edges (FaceColor, EdgeColor).

    load wind
    wind_speed = sqrt(u.^2 + v.^2 + w.^2);
    hiso = patch(isosurface(x,y,z,wind_speed,40));
    isonormals(x,y,z,wind_speed,hiso)
    set(hiso,'FaceColor','red','EdgeColor','none');

2. Add Isocaps to the Isosurface

Isocaps are similar to slice planes in that they show a cross section of the volume. They are designed to be the end caps of isosurfaces. Using interpolated face color on an isocap causes a mapping of data value to color in the current colormap. To create isocaps for the isosurface, define them at the same isovalue (isocaps, patch, colormap).

hcap = patch(isocaps(x,y,z,wind_speed,40),...
    'FaceColor','interp',...
    'EdgeColor','none');
colormap hsv

3. Create the First Set of Cones

4. Create Second Set of Cones

  1. Create a second set of points at values that span the data range (linspace, meshgrid).

  2. Draw a second set of cones and set the face color to green and the edge color to none.

    xrange = linspace(min(x(:)),max(x(:)),10);
    yrange = linspace(min(y(:)),max(y(:)),10);
    zrange = 3:4:15;
    [cx,cy,cz] = meshgrid(xrange,yrange,zrange);
    h2 = coneplot(x,y,z,u,v,w,cx,cy,cz,2);
    set(h2,'FaceColor','green','EdgeColor','none');

5. Define the View

  1. Use the axis command to set the axis limits equal to the minimum and maximum values of the data and enclose the graph in a box to improve the sense of a volume (box).

  2. Set the projection type to perspective to create a more natural view of the volume. Set the viewpoint and zoom in to make the scene larger (camproj, camzoom, view).

    axis tight
    box on
    camproj perspective
    camzoom(1.25)
    view(65,45)

6. Add Lighting

Add a light source and use Phong lighting for the smoothest lighting of the isosurface (Phong lighting requires the Z-buffer renderer). Increase the strength of the background lighting on the isocaps to make them brighter (camlight, lighting, AmbientStrength).

camlight(-45,45)
set(gcf,'Renderer','zbuffer'); 
lighting phong
set(hcap,'AmbientStrength',.6)

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS