How to plot volumetric concentration points in a slice meshgrid?

4 ビュー (過去 30 日間)
Timofey Broslav
Timofey Broslav 2018 年 5 月 4 日
編集済み: Timofey Broslav 2018 年 5 月 4 日
Hello,
I have a 2-D array A(time, concentration value at a z value). I would like to use this for my mesh grid for each time step. i.e for grid 1 it will be (1, concentration values in z) then grid two would have (2, concentration values in z). I made the assumption that the concentration at each z point will be equal for the y and x plane. So far I have the code shown below, however, the plot i get is a blank white plot. I think i need to make v dependent on xp,yp, and zp, but I do not know how to do that. Anyone have any ideas how to implement this?
Thank you
dx = 6.35/120;
dy = 5.08/120;
dz = (0.01+0.0111)/120;
xp = 0:dx:6.35;
yp = 0:dy:5.08;
zp= 0 :dz:(0.01+0.0111);
[xp,yp,zp] = meshgrid(xp,yp,zp);
for j = 1:10000
v = B(:,j);
xslice = [3.175,6.35]; % location of y-z planes
yslice = [2,5.089]; % location of x-z plane
zslice = [0,.0111]; % location of x-y planes
slice(xp,yp,zp,v,xslice,yslice,zslice)
xlabel('x')
ylabel('y')
zlabel('z')
end
Where B is a (120 x 80000) double. With 120 z time steps and 80000 time steps.
  2 件のコメント
Wick
Wick 2018 年 5 月 4 日
編集済み: Wick 2018 年 5 月 4 日
You're not just getting a blank plot. You're getting an error message that 'V must be a 3-D array.'
The trouble is this line in your code:
v = B(:,j);
As you said, B is a [120 x 80000] 2D matrix. The line above is going to select the j'th row of B. So v is a [1 x 80000] vector. If you're going to use the 'slice' command with xp,yp, and zp, v has to be a [121 x 121 x 121] array.
While you're looking at that, may I suggest you read up on the 'linspace' command. Rather than solving for dx and then defining xp, you could replace both of those lines with:
xp = linspace(0,6.35,121);
Edit: and I just realized that you probably wanted XP, et al to be [120x120x120] to match the number of rows in B. Using the colon to define a vector the way you did will end up including the ends on either side of 120 spaces. Use the 'linspace' command instead with the number of elements at 120 and you don't have to worry about whether the last increment will land exactly on the limit or overshoot it.
Timofey Broslav
Timofey Broslav 2018 年 5 月 4 日
Would you know how I would be able to create a more smooth image while keeping all concentration points (120x120x120)? This just looks ugly. I am also looking into displaying a color scale, if you have any hints on that.

サインインしてコメントする。

採用された回答

Wick
Wick 2018 年 5 月 4 日
Ok, looks like you've got your volumetric plots going. It's easy from here.
First, to display a color scale, the command is
colorbar
Second, to explain how to get rid of the black lines you've got to understand something called handles. MATLAB represents its graphics in a series of nested structures called graphics handles. When you create a plot object you can usually assign the output to a variable. That will assign that variable the handle of that object. You can then interrogate the properties of that object by using the 'get' command. You can 'set' properties to change them. I recommend looking at the halp for more detail. However, for your case, it's just going to be:
h = slice(X,Y,Z,V,Sx,Sy,Sz);
set(h,'EdgeColor','none');
  1 件のコメント
Timofey Broslav
Timofey Broslav 2018 年 5 月 4 日
編集済み: Timofey Broslav 2018 年 5 月 4 日
Thank you Chad, here is what I got. (btw I had to flip around my z limits because I realized it was upside down haha)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by