www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/StreamlinePlotWithSlicePlanesOfContourPlotsExample.m
%% Display Slice Planes and Plot Streamlines % This example shows how to use slice planes to create cross-sectional views % of data, add contour plots to the slice planes, and plot stream lines. % Copyright 2015 The MathWorks, Inc. %% Determine the Range of Coordinates % Load the |wind| data set to get arrays |x|, |y|, |z|, |u|, |v|, and |w|. % Determine the maximum and minimum values to locate the slice planes and % contour plots. load wind xmin = min(x(:)); xmax = max(x(:)); ymax = max(y(:)); zmin = min(z(:)); %% Add Slice Planes % Calculate the magnitude of the vector field, which represents the wind % speed, to generate scalar data for the |slice| function. wind_speed = sqrt(u.^2 + v.^2 + w.^2); %% % Create slice planes along the _x_-axis at the values |xmin|, 100, % and |xmax|. Locate them along the _y_-axis at |ymax| and % along the _z_-axis at |zmin|. Specify interpolated face coloring so the % slice coloring indicates wind speed. Set the |EdgeColor| of the slices to |'none'| to % draw them without edges. figure s = slice(x,y,z,wind_speed,[xmin,100,xmax],ymax,zmin); set(s,'FaceColor','interp','EdgeColor','none') %% Add Contour Lines to Slice Planes % Draw contour lines on the slice planes. Store the patch handles created % by |contourslice| as |p|. Set the edge color and the line width of the % patches. p = contourslice(x,y,z,wind_speed,[xmin,100,xmax],ymax,zmin); set(p,'EdgeColor',[0.7,0.7,0.7],'LineWidth',0.5) %% Add Stream Lines % Plot streamlines starting from an _x_-value of 80. % Plot the streamlines so that they span _y_-values between 20 and 50 % and _z_-values between 0 and 15. Use thick red lines for % the streamlines. xspan = 80; yspan = 20:10:50; zspan = 0:5:15; [sx,sy,sz] = meshgrid(xspan,yspan,zspan); l = streamline(x,y,z,u,v,w,sx,sy,sz); set(l,'LineWidth',2,'Color','r')