Volumetric slice plot missing data

7 ビュー (過去 30 日間)
Sean Kelley
Sean Kelley 2018 年 2 月 4 日
回答済み: Hans Ruder 2023 年 6 月 8 日
Matlab documentation provides the example below for a volumetric slice plot. The size of the 3D array is 17x21x26. However, the slice command only plots 16x20x25. Each axis is missing its last column/row of data points. Looking closely at the planar yslice=0, you can see that the y=0 plane is situated in the middle of a unit step. So basically, MATLAB is cutting one row/column of x, y, and z and not displaying the data then adjusting the plot to be symmetric by placing y=0 in the middle of a unit step.
I'm plotting a 3D array called Temp_xtal with size of 128x128x12. (The rotated slice plot below has z-axis running left to right and looking at the y-z plane). When I plot... [xx,yy,zz] = meshgrid(-64:1:64,-64:1:64,1:1:12); xslice = 0; yslice = 0; zslice = 0; slice(xx,yy,zz,Temp_xtal,xslice,yslice,zslice) ...MATLAB returns an error. If I change it to [xx,yy,zz] = meshgrid(-64:1:63,-64:1:63,1:1:12); then it plots, but is missing a slice along the z-axis, even though zz ranges over 1:1:12. The plot only shows 11 of the 12 slices along my z-axis and 127 of the 128 slices along x-axis and y-axis (x-y planar slices are perpindicular to the page here, represented by vertical lines).
Another observation is that the slice of missing data is actually slice#12, not slice #1. If I plot [xx,yy,zz] = meshgrid(-64:1:63,-64:1:63,0:1:11); then the data shifts left along z-axis, which is correct but still missing the 12th slice of data.
This behavior is the same as what is shown in the MATLAB documentation example. Is there a way to plot all of my data without omitting the last slice?
  1 件のコメント
Hans Ruder
Hans Ruder 2022 年 10 月 3 日
I noticed the same problem. Seems to be a bug. Symmetric functions are not symmetric when plotting with slice.

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

回答 (2 件)

Bjorn Gustavsson
Bjorn Gustavsson 2022 年 10 月 3 日
This is a well-known feature of the pcolor-surf-slice functions. If they are given arrays x, y and V (for pcolor and surf) the value displayed on the patch with corners at [x(i1),y(i2)] - [x(i1+1),y(i2)] - [x(i+1),y(i2+1)] - [x(i1),y(i2+1)] will be the value V(i1,i2). The behaviour extends into 3-D with slice. While I was displaying many surfaces with few elements I wrote wrappers to these functions such that I could send in arrays x, y (and z) with coordinates for the corners of all elements in V such that matlab would show me the full surfaces. This was something as simple as:
function ph = pcolor_full(x,y,V)
Vfull = V;
Vfull(end+1,:) = Vfull(end,:);
Vfull(:,end+1) = Vfull(:,end);
ph = pcolor(x,y,Vfull);
end
This would work if I sent in x and y arrays one element smaller than V.
You should be able to do the same for slice.

Hans Ruder
Hans Ruder 2023 年 6 月 8 日
Your meshgrid(-64:1:64,-64:1:64,1:1:12) has size 129x129x12, that's why you cannot plot it with Temp_xtal with size of 128x128x12.
You could use:
pts = linspace(-64,64,128)
[xx,yy,zz] = meshgrid(pts,pts,1:1:12)
The asymmetric display of symmetric functions when plotting with slice can be resolved by using shading('interp') instead of the default shading('faceted').

カテゴリ

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