1257 1

MATLAB课程:代码示例之Graphics and Visualization(三) [推广有奖]

企业贵宾

已卖:160份资源

巨擘

0%

还不是VIP/贵宾

-

威望
4
论坛币
624047 个
通用积分
180.4253
学术水平
918 点
热心指数
987 点
信用等级
841 点
经验
399113 点
帖子
9786
精华
48
在线时间
17322 小时
注册时间
2014-8-19
最后登录
2022-11-2

楼主
widen我的世界 学生认证  发表于 2016-3-8 14:48:25 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

MATLAB课程:代码示例之Graphics and Visualization(三)


Visualizing Volume Data


This example shows several methods for visualizing volume data in MATLAB®.


Display Isosurface

An isosurface is a surface where all the points within a volume of space have a constant value. Use the isosurface function to generate the faces and vertices for the outside of the surface and the isocaps function to generate the faces and vertices for the end caps of the volume. Use the patch command to draw the volume and its end caps.

load mri D                                     % load dataD = squeeze(D);                                % remove singleton dimensionlimits = [NaN NaN NaN NaN NaN 10];[x, y, z, D] = subvolume(D, limits);           % extract a subset of the volume data[fo,vo] = isosurface(x,y,z,D,5);               % isosurface for the outside of the volume[fe,ve,ce] = isocaps(x,y,z,D,5);               % isocaps for the end caps of the volumefigurep1 = patch('Faces', fo, 'Vertices', vo);       % draw the outside of the volumep1.FaceColor = 'red';p1.EdgeColor = 'none';p2 = patch('Faces', fe, 'Vertices', ve, ...    % draw the end caps of the volume   'FaceVertexCData', ce);p2.FaceColor = 'interp';p2.EdgeColor = 'none';view(-40,24)daspect([1 1 0.3])                             % set the axes aspect ratiocolormap(gray(100))box oncamlight(40,40)                                % create two lightscamlight(-20,-10)lighting gouraud


Create Cone Plot

The coneplot command plots velocity vectors as cones at x, y, z points in a volume. The cones represent the magnitude and direction of the vector field at each point.

cla                                            % clear the current axesload wind u v w x y z                          % load data[m,n,p] = size(u);[Cx, Cy, Cz] = meshgrid(1:4:m,1:4:n,1:4:p);    % calculate the location of the conesh = coneplot(u,v,w,Cx,Cy,Cz,y,4);              % draw the cone plotset(h,'EdgeColor', 'none')axis tight equalview(37,32)box oncolormap(hsv)light


Plot Streamlines

The streamline function plots streamlines for a velocity vector at x, y, z points in a volume to illustrate the flow of a 3-D vector field.

cla[m,n,p] = size(u);[Sx, Sy, Sz] = meshgrid(1,1:5:n,1:5:p);    % calculate the starting points of the streamlinesstreamline(u,v,w,Sx,Sy,Sz)                 % draw the streamlinesaxis tight equalview(37,32)box on


Plot Streamtubes

The streamtube function plots streamtubes for a velocity vector at x, y, z points in a volume. The width of the tube is proportional to the normalized divergence of the vector field at each point.

cla[m,n,p] = size(u);[Sx, Sy, Sz] = meshgrid(1,1:5:n,1:5:p);    % calculate the starting points of the streamlinesh = streamtube(u,v,w,Sx,Sy,Sz);            % draw the streamtubes and return an array of surfacesset(h, 'FaceColor', 'cyan')                % use 'set' to change properties for an array of objectsset(h, 'EdgeColor', 'none')axis tight equalview(37,32)box onlight


Combine Volume Visualizations

Combine volume visualization in a single plot to get a more comprehensive picture of a velocity field within a volume.

claspd = sqrt(u.*u + v.*v + w.*w);                          % wind speed at each point in the volume[fo,vo] = isosurface(x,y,z,spd,40);                      % isosurface for the outside of the volume[fe,ve,ce] = isocaps(x,y,z,spd,40);                      % isocaps for the end caps of the volumep1 = patch('Faces', fo, 'Vertices', vo);                 % draw the isosurface for the volumep1.FaceColor = 'red';p1.EdgeColor = 'none';p2 = patch('Faces', fe, 'Vertices', ve, ...              % draw the end caps of the volume   'FaceVertexCData', ce);p2.FaceColor = 'interp';p2.EdgeColor = 'none' ;[fc, vc] = isosurface(x, y, z, spd, 30);                 % isosurface for the cones[fc, vc] = reducepatch(fc, vc, 0.2);                     % reduce the number of faces and verticesh1 = coneplot(x,y,z,u,v,w,vc(:,1),vc(:,2),vc(:,3),3);    % draw the coneploth1.FaceColor = 'cyan';h1.EdgeColor = 'none';[sx, sy, sz] = meshgrid(80, 20:10:50, 0:5:15);           % starting points for streamlineh2 = streamline(x,y,z,u,v,w,sx,sy,sz);                   % draw the streamlinesset(h2, 'Color', [.4 1 .4])axis tight equalview(37,32)box onlight




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:MATLAB课程 Graphics GRAPHIC MATLAB Visual MATLAB课程 代码示例 GraphicsandVisualization VisualizingVolumeData


https://www.cda.cn/?seo-luntan
高薪就业·数据科学人才·16年教育品牌

沙发
离婚律师 在职认证  发表于 2016-3-8 14:49:05
厉害,太爽了这种弄的……

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-9 06:06