Matlab流体后处理中的奇淫巧术总结

主要参考\demos\volvec.m示例

1.等值面绘制

%% Isosurface of MRI Data
cla
load mri
D = squeeze(D);
[x, y, z, D] = subvolume(D, [nan nan nan nan nan 4]);
p = patch(isosurface(x,y,z,D, 5), 'FaceColor', 'red', 'EdgeColor', 'none');
patch(isocaps(x,y,z,D, 5), 'FaceColor', 'interp', 'EdgeColor', 'none');
isonormals(x,y,z,D,p);
view(3)
daspect([1 1 .4])
colormap(gray(100))
camva(9)
box on
camlight(40, 40)
camlight(-20,-10)
lighting gouraud
  • isosurface(x,y,z,D, 5)

参数意义为,从由X,Y,Z构造的体积V数据中提取由isovalue指定的等值数据,返回结果为一个结构体,包含了等值面的顶点和面(顶点的次序),这些参数可以直接传给patch命令画出图形来。

2.圆锥体流线图绘制

cla
load wind
[cx, cy, cz] = meshgrid(linspace(71,134,10),linspace(18,59,10),3:4:15);
daspect([1 1 1]) % gca, 'DataAspectRatio' 属性设置
h = coneplot(x,y,z,u,v,w,cx,cy,cz,y,3);
set(h,'EdgeColor', 'none')
colormap(hsv)
box on
axis tight % 使坐标系的最大值和最小值和你的数据范围一致
camproj perspective
camva(35) % Camera view angle.
campos([175 10 85]) % Camera position.
camtarget([105 40 0]) % Camera target. (三维图形质心)
camlight left % Create or set position of a light.
lighting gouraud % 查看曲面单元时使用lighting gouraud 或 lighting phong
  • h = coneplot(x,y,z,u,v,w,cx,cy,cz,y,3);

用圆锥体绘制三维流速图,x,y,z,u,v,w是流速场分布,cx,cy,cz是圆锥体位置

3.绘制流线图

cla
[sx, sy, sz] = meshgrid(80, 20:10:50, 0:5:15);
h = streamline(x,y,z,u,v,w,sx,sy,sz);
set(h, 'Color', 'cyan')
daspect([1 1 1])
box on
camproj perspective
camva(32)
axis tight
campos([175 10 85])
camtarget([105 40 0])
camlight left
lighting gouraud
  • h = streamline(x,y,z,u,v,w,sx,sy,sz);

x,y,z,u,v,w是流速场分布,sx,sy,sz定义了流线起点。(有关如何定义流线起始点问题,请参考附录B)

4.流管图

cla
[sx, sy, sz] = meshgrid(80, [20 30 40], [5 10]);
daspect([1,1,1])
h = streamtube(x,y,z,u,v,w,sx,sy,sz);
set(h,'facecolor','cyan','edgecolor','none')
box on
camproj perspective
axis([70 138 17 60 2.5 16])
axis tight
camva(28)
campos([175 10 95])
camtarget([105 40 0])
camlight left
lighting gouraud
  • h = streamtube(x,y,z,u,v,w,sx,sy,sz);

    streamtube(X,Y,Z,U,V,W,STARTX,STARTY,STARTZ) draws stream

    tubes from vector data U,V,W. The arrays X,Y,Z define the

    coordinates for U,V,W and must be monotonic and 3D plaid (as if

    produced by MESHGRID). STARTX, STARTY, and STARTZ define the

    starting positions of the streamlines at the center of the

    tubes. The width of the tubes is proportional to the normalized divergence of the vector field. A vector of surface

    handles (one per start point) is returned in H.

    矢量管的粗细和该点处散度有关

5.流线带图

cla
[sx, sy, sz] = meshgrid(80, [20 30 40], [5 10]);
daspect([1,1,1])
h = streamribbon(x,y,z,u,v,w,sx,sy,sz);
set(h,'facecolor','cyan','edgecolor','none')
box on
camproj perspective
axis([70 138 17 60 2.5 16])
axis tight
camva(28)
campos([175 10 85])
camtarget([105 40 0])
camlight left
lighting gouraud
  • h = streamribbon(x,y,z,u,v,w,sx,sy,sz);

    streamribbon(X,Y,Z,U,V,W,STARTX,STARTY,STARTZ) draws stream

    ribbons from vector data U,V,W. The arrays X,Y,Z define the

    coordinates for U,V,W and must be monotonic and 3D plaid (as if

    produced by MESHGRID). STARTX, STARTY, and STARTZ define the

    starting positions of the streamlines at the center of the

    ribbons. The twist of the ribbons is proportional to the

    curl of the vector field. The width of the ribbons is

    calculated automatically.

附录A.Accessing Subregions of Volume Data

The subvolume function provides a simple way to access subregions of a volume data set. subvolume enables you to select regions of interest based on limits rather than using the colon operator to index into the 3-D arrays that define volumes. Consider the following two approaches to creating the data for a subvolume — indexing with the colon operator and using subvolume.

Indexing with the Colon Operator

When you index the arrays, you work with values that specify the elements in each dimension of the array.

load wind
xsub = x(1:10,20:30,1:7);
ysub = y(1:10,20:30,1:7);
zsub = z(1:10,20:30,1:7);
usub = u(1:10,20:30,1:7);
vsub = v(1:10,20:30,1:7);
wsub = w(1:10,20:30,1:7);

Using the subvolume Function

subvolume enables you to use coordinate values that you can read from the axes. For example:

lims = [100.64 116.67 17.25 28.75 -0.02 6.86];
[xsub,ysub,zsub,usub,vsub,wsub] = subvolume(x,y,z,u,v,w,lims);

You can then use the subvolume data as inputs to any function requiring vector volume data.

附录B.Specifying Starting Points for Stream Plots

Stream plots (stream lines, ribbons, tubes, and cones or arrows) illustrate the flow of a 3-D vector field. The MATLAB stream-plotting functions (streamline, streamribbon, streamtube, coneplot, stream2, stream3) all require you to specify the point at which you want to begin each stream trace.

Determining the Starting Points

Generally, knowledge of your data's characteristics helps you select the starting points. Information such as the primary direction of flow and the range of the data coordinates helps you decide where to evaluate the data.

The streamslice function is useful for exploring your data. For example, these statements draw a slice through the vector field at a z value midway in the range.

load wind
zmax = max(z(:)); zmin = min(z(:));
streamslice(x,y,z,u,v,w,[],[],(zmax-zmin)/2)

This stream slice plot indicates that the flow is in the positive x-direction and also enables you to select starting points in both x and y. You could create similar plots that slice the volume in the x-z plane or the y-z plane to gain further insight into your data's range and orientation.

Specifying Arrays of Starting-Point Coordinates

To specify the starting point for one stream line, you need the x-, y-, and z-coordinates of the point. The meshgrid command provides a convenient way to create arrays of starting points. For example, you could select the following starting points from the wind data displayed in the previous stream slice.

[sx,sy,sz] = meshgrid(80,20:10:50,0:5:15);

This statement defines the starting points as all lying on x = 80, y ranging from 20 to 50, and z ranging from 0 to 15. You can use plot3 to display the locations.

plot3(sx(:),sy(:),sz(:),'*r');
axis(volumebounds(x,y,z,u,v,w))
grid on
set(gca,'BoxStyle','full','Box','on')
daspect([2 2 1])

You do not need to use 3-D arrays, such as those returned by meshgrid, but the size of each array must be the same, and meshgrid provides a convenient way to generate arrays when you do not have an equal number of unique values in each coordinate. You can also define starting-point arrays as column vectors. For example, meshgrid returns 3-D arrays:

[sx,sy,sz] = meshgrid(80,20:10:50,0:5:15);
whos
Name Size Bytes Class Attributes sx 4x1x4 128 double
sy 4x1x4 128 double
sz 4x1x4 128 double

In addition, you could use 16-by-1 column vectors with the corresponding elements of the three arrays composing the coordinates of each starting point. (This is the equivalent of indexing the values returned by meshgrid as sx(, sy(, and sz(.)

For example, adding the stream lines to the starting points produces:

streamline(x,y,z,u,v,w,sx(:),sy(:),sz(:))

Matlab流体后处理中的奇淫巧术总结的更多相关文章

  1. PHP渗透中的奇淫技巧--检查相等时的漏洞

    PHP是现在网站中最为常用的后端语言之一,是一种类型系统 动态.弱类型的面向对象式编程语言.可以嵌入HTML文本中,是目前最流行的web后端语言之一,并且可以和Web Server 如apache和n ...

  2. Java语言中的奇淫技巧

    variable length parameter list(可变长度参数列表) 很久之前了解过有这么一种写法,但转眼即忘.今天在公司项目的代码里看到,有点小惊讶,写这代码的同事还是有点水平的...

  3. [asp.net mvc 奇淫巧技] 01 - 封装上下文 - 在View中获取自定义的上下文

    我们在asp.net 开发中已经封装了最强大的HttpContext,我们可以在HttpContext中可以获取到几乎任何想获取的东西,也可以在HttpContext写入需要返回客户端的信息.但是这些 ...

  4. [asp.net mvc 奇淫巧技] 02 - 巧用Razor引擎在Action内生成Html代码

    在web开发中经常会遇到在内部代码中获取Html,这些Html是需要和数据进行一起渲染.并不是直接把Html代码返回给客户端.这样的做法有很多应用场景,例如分页.Ajax一次性获取几段Html片段.生 ...

  5. 你可能不知道的 docker 命令的奇淫怪巧

    你可能不知道的 docker 命令的奇淫怪巧 Intro 介绍并收录一些可能会用到的一些简单实用却很少有人用的 docker 命令 dangling images build 自己的 docker 镜 ...

  6. [asp.net mvc 奇淫巧技] 03 - 枚举特性扩展解决枚举命名问题和支持HtmlHelper

    一.需求 我们在开发中经常会遇到一些枚举,而且这些枚举类型可能会在表单中的下拉中,或者单选按钮中会用到等. 这样用是没问题的,但是用过的人都知道一个问题,就是枚举的命名问题,当然有很多人枚举直接中文命 ...

  7. [asp.net mvc 奇淫巧技] 04 - 你真的会用Action的模型绑定吗?

    在QQ群或者一些程序的交流平台,经常会有人问:我怎么传一个数组在Action中接收.我传的数组为什么Action的model中接收不到.或者我在ajax的data中设置了一些数组,为什么后台还是接收不 ...

  8. [asp.net mvc 奇淫巧技] 05 - 扩展ScriptBundle,支持混淆加密javascript

    一.需求: 在web开发中,经常会处理javascript的一些问题,其中就包括js的压缩,合并,发布版本以及混淆加密等等问题.在asp.net 开发中我们使用ScriptBundle已经可以解决ja ...

  9. [asp.net mvc 奇淫巧技] 06 - 也许你的项目同一个用户的请求都是同步的

    一.感慨 很久前看到一篇博客中有句话大致的意思是:“asp.net 程序性能低下的主要原因是开发人员技术参差不齐”,当时看到这句话不以为然,然而时间过的越久接触的.net 开发人员越多就越认同这句话: ...

随机推荐

  1. keras框架下的深度学习(二)二分类和多分类问题

    本文第一部分是对数据处理中one-hot编码的讲解,第二部分是对二分类模型的代码讲解,其模型的建立以及训练过程与上篇文章一样:在最后我们将训练好的模型保存下来,再用自己的数据放入保存下来的模型中进行分 ...

  2. mysql分表之后怎么平滑上线?

    分表的目的 项目开发中,我们的数据库数据越来越大,随之而来的是单个表中数据太多.以至于查询数据变慢,而且由于表的锁机制导致应用操作也受到严重影响,出现了数据库性能瓶颈. 当出现这种情况时,我们可以考虑 ...

  3. Noip模拟36 2021.8.11

    刚题的习惯还是改不了,怎么办??? T1 Dove打扑克 考场上打的动态开点线段树+并查集,考后发现自己像一个傻子,并查集就行.. 这几天恶补数据结构疯了 用树状数组维护后缀和,$siz_i$表示编号 ...

  4. BF算法和KMP算法

    这两天复习数据结构(严蔚敏版),记录第四章串中的两个重要算法,BF算法和KMP算法,博主主要学习Java,所以分析采用Java语言,后面会补上C语言的实现过程. 1.Brute-Force算法(暴力法 ...

  5. MyBatis源码分析(三):MyBatis初始化(配置文件读取和解析)

    一. 介绍MyBatis初始化过程 项目是简单的Mybatis应用,编写SQL Mapper,还有编写的SqlSessionFactoryUtil里面用了Mybatis的IO包里面的Resources ...

  6. 矩阵中的路径 牛客网 剑指Offer

    矩阵中的路径 牛客网 剑指Offer 题目描述 请设计一个函数,用来判断在一个矩阵中是否存在一条包含某字符串所有字符的路径.路径可以从矩阵中的任意一个格子开始,每一步可以在矩阵中向左,向右,向上,向下 ...

  7. Zabbix webhook 自定义报警媒介

    场景一:使用企业微信机器人报警 图中的token是:在群组中添加机器人,机器人的webhook地址的key var Wechat = { token: null, to: null, message: ...

  8. SpringCloud 2020.0.4 系列之 Gateway入门

    1. 概述 老话说的好:做人要有幽默感,懂得幽默的人才会活的更开心. 言归正传,今天我们来聊聊 SpringCloud 的网关组件 Gateway,之前我们去访问 SpringCloud 不同服务的接 ...

  9. Linux&C 线程控制 课后习题

    Q1:多线程与多进程相比有什么优势? 多进程程序耗费的资源大,因为fork()的时候子进程需要继承父进程的几乎所有东西,但是多线程程序线程只继承一部分,即自己的私有数据,例如自己的线程ID,一组寄存器 ...

  10. 执行新程序 execve()

    新程序的执行 一:execve() 之所以叫新程序的执行,原因是这部分内容一般发生在fork()和vfork()之后,在子进程中通过系统调用execve()可以将新程序加载到子进程的内存空间.这个操作 ...