Problem in displaying slice and contourslice plot

5 次查看(过去 30 天)
When i assign some value to a particular plane in a 3d matrix, Matlab automatically averages top and bottom plane shows some value as if it has been assigned programmically. Will that affect simulation??
Given the code below:
e=ones(10,10,10);
e(:,:,8)=5;
slice(e,[],[],7:0.5:9);
If we execute the above code, it shows some values at z=7.5 and z=8.5 where there is no definition !! Is there a solution to avoid all these averaging in slice plot and contourslice plot

回答(1 个)

Walter Roberson
Walter Roberson 2015-11-7
... Don't ask it to display at positions where there is no data?
slice(e,[],[],7:1:9)
  3 个评论
Walter Roberson
Walter Roberson 2015-11-7
Look at the documentation for slice() again:
slice(...,'method') specifies the interpolation method. 'method' is 'linear', 'cubic', or 'nearest'.
linear specifies trilinear interpolation (the default).
cubic specifies tricubic interpolation.
nearest specifies nearest-neighbor interpolation.
Notice the default of 'linear'. Therefore if you ask for data at coordinates which are not exactly in the X, Y, Z input coordinates given (or inferred) then the data is going to be interpolated from the known data. This is a primary function of slice(). If you do not want interpolation then do not ask to draw at coordinates that do not exist in the input.
"if some further parameters are calculated" -- are calculated by what?
"will it affect simulation" -- No, not unless you are reading the data out of the graphic and using it to compute with. slice() is for producing graphics, not for extracting data for computation purposes.
If your purpose is to extract data for calculation purposes, then just index the data:
extracted_data = e(:,:,7:9);
Sundaram  SM
Sundaram SM 2015-11-7
Thanks for clarification. I am not sure the question is taken in right spirit. I am well aware that slice is for producing graphics and I just had a doubt which was mentioned in the question.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interpolation of 2-D Selections in 3-D Grids 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by