Slice does not output correct cdata
2 views (last 30 days)
Show older comments
Kind all,
I am having troubles in using the "slice" command in MATLAB. I have a 3D variable representing the plume of a pollutant, which I am able to visualize with contourslice:
contourslice(Xgrid,Ygrid,Zgrid,myvolume,[],[],all_the_z_levels)
where Xgrid, Ygrid, Zgrid represent the 3D meshgridding of the 3 vectors (xgrid,ygrid,zgrid) representing the 3 dimensions of my volume. All vectors are in meters.
Here's the output of my command:
As you can see my plume rises well above floor (and all zero values outside the plume have been masked to NaNs).
Now let's assume I want to take a slice of my rising plume with the following command:
h=slice(Xgrid,Ygrid,Zgrid,myvolume,xgrid(130),[],[],[]);
This means I'm slicing my volume on the x-axis at the 130th index of my xgrid vector with a single slice. Here's the output:
The expected slice would be a matrix of NaNs except where the plume is where the value of the plume are expected. You can already see from the figure that something's wrong: there is some values bleeding all down to the "ground" where no plume is residing.
In case it's not clear here's the output of the following command:
c1=get(h,'CData');
contourf(ygrid,zgrid,c1') % it's an x-plane slice, so it's plotted against y-plane and elevation
% c1 is transposed because, by some reason, even if my volume is 200(x)*200(y)*100(z), MATLAB returns a
% 100*200 slice instead of a 200*100 one
There's clearly something wrong here, since there should be no plume going to ground level. The same output is obtained with an ex-novo slice running:
xs=get(h,'xdata');
ys=get(h,'ydata');
zs=get(h,'zdata');
h2=slice(Xgrid,Ygrid,Zgrid,my_volume,xs,ys,zs) % create new slice with the x,y,z data of the original one
c2=get(h2,'CData');
contourf(ygrid,zgrid,c2');
What's wrong? Am I doing something non correctly? Are there are known bugs on the "slice" command?
0 Comments
Answers (0)
See Also
Categories
Find more on Volume Visualization in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!