Problem in displaying slice and contourslice plot

조회 수: 4 (최근 30일)
Sundaram  SM
Sundaram SM 2015년 11월 7일
댓글: Sundaram SM 2015년 11월 7일
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