이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
3D plot help
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I have a row data composed of independent variables x, y, and z and a dependent variable D, and I would like to 3d plot the geometry. Each independent and dependent variable is a 1D array. However, all 3d plotting functions that I am aware of such as isosurface require 3D arrays. My question is how I can transfom the different arrays into 3d arrays, given that they are not uniform.
댓글 수: 21
Walter Roberson
2019년 8월 27일
griddata() .
Or possibly you could
ux = unique(x);
uy = unique(y);
uz = unique(z);
D3 = reshape(D, length(ux), length(uy), length(uz));
and then isosurface() on D3
Diab Abueidda
2019년 8월 27일
Thanks, Walter for the reply.
I did as you suggested:
ux = unique(x);
uy = unique(y);
uz = unique(z);
D3 = reshape(D, length(ux), length(uy), length(uz));
and received the following error
Error using reshape
To RESHAPE the number of elements must not change.
Error in IsoSurface (line 12)
D3 = reshape(D, length(ux), length(uy), length(uz));
Also, I don't think unique function is what I need. In my case, x, y, and z are three spatial coordinates. Hence, some data points will share one or two coordinates, but the remaining coordinates will be different. In this sense, I don't have a problem of nonuniqueness.
Walter Roberson
2019년 8월 27일
편집: Walter Roberson
2019년 8월 28일
Your original line about "Each independent and dependent variable is a 1D array." was not clear. If each one is a 1D array, then that would imply that the variables are independent and that you have all combinations of values available. If that is not the case, then see griddata() that I mentioned before.
Diab Abueidda
2019년 8월 28일
Thanks, Walter for the reply.
I think griddata is in the right direction, but still I am not getting what I am expecting. The code I am using is
D = xval;
minv= 0; maxv=10; inc=0.05;
[xq,yq,zq]=meshgrid(minv:inc:maxv,minv:inc:maxv,minv:inc:maxv);
Dq = griddata(x,y,z,D,xq,yq,zq,'linear');
margin = 0.1;
xb_index = [find(xq<=minv+margin) find(xq>=maxv-margin)];
yb_index = [find(yq<=minv+margin) find(yq>=maxv-margin)];
zb_index = [find(zq<=minv+margin) find(zq>=maxv-margin)];
cutoff = 0.5;
Dq(xb_index)=cutoff;
Dq(yb_index)=cutoff;
Dq(zb_index)=cutoff;
p1 = patch(isosurface(xq,yq,zq,Dq, cutoff),'FaceColor','blue','EdgeColor','none');
% p2 = patch(isocaps(xq,yq,zq,Dq, cutoff+0.1),'FaceColor','cyan','EdgeColor','none');
view(3);
axis tight
camlight
lighting gouraud
daspect([1,1,1])
isonormals(Dq,p1)
If I use 'nearest' for griddata I get this,
![nearest.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/235591/nearest.jpeg)
I get what I need as a closed geometry, but it is not smooth. I changed the method to natural. I started getting a bit smoother isosurface, but I could not close the sides of the geometry. Please see below
![natural.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/235592/natural.jpeg)
Any recommendation?
Walter Roberson
2019년 8월 29일
I think I will need the data to play with. It is not obvious from the scatter plot that any semi-regular structure exists inside that at all.
Walter Roberson
2019년 8월 31일
I will need the D as well.
I was correct in my original speculation that you have a regular 3D grid of data.
Diab Abueidda
2019년 8월 31일
Hi Walter,
Thanks for the reply. Please find the data attached.
The data I sent indeed has a regular 3D grid, but please note that this is the simplest case I have, and it is the only one with a regular grid. What I am trying to write is a code that is applicable for all cases, and I am still failing to obtain the geometry even with the simplest case.
Thanks for the support.
Walter Roberson
2019년 9월 1일
I did have a look, but I couldn't figure out why I was getting the visuals that I was getting.
One thing I do not understand is why you assign 0.5 to locations in the margins, considering that the value distribution is "a lot of values near 0.1" and "a lot of values near 0.9" together with an equal but much smaller distribution of values in-between. It would seem more natural to assign 0 or nan to the margin.
Diab Abueidda
2019년 9월 1일
Hi Walter,
Thanks for having a look. The values are obtained mathematically by using an optimization framework. Physically, the densities should be binary (zero or one), but we relax this condition and apply penalization to push the density either to zero or one. For numerical stability purposes, we put a minimum value for densities to be 0.001.
Regarding the assigned threshold, any value from 0.3 to 0.7 should be physically acceptable. Feel free to change it.
I hope this gives you an overview of the problem.
Walter Roberson
2019년 9월 1일
When I look at the data with a 3D visualizer, I can see that there is something that is roughly X shaped, and I do not see anything special happening in the margins. I do not understand why a higher cutoff is being assigned than the values.
If you let H be high values near 0.9, and L be low values near 0.01 then you get a shape that near the top is roughly
HHLLLLLLLLHH
LHHLLLLLLHHL
LLHHLLLLHHLL
LLLHHLLHHLLL
LLLLHHHHLLLL
and I do not understand why you want to modify that to
MMMMMMMMMMMM
MHHLLLLLLHHM
MLHHLLLLHHLM
MLLHHLLHHLLM
MLLLHHHHLLLM
This introduces a "flange" into the visuals that I do not see a purpose for.
Diab Abueidda
2019년 9월 1일
I added this part to close the isosurface at the boundaries. Otherwise, I would get two isosurfaces as shown in the second figure I shared. I believe that this part I added closed the geometry as portrayed in Figure 1. Is there a better way to close the geometry? I tried to use isocaps as shown in the shared code, but still I had the same problem.
Diab Abueidda
2019년 9월 2일
Hi Walter,
Regardless of the code I wrote, how would you do it? Basically, I need to get something similar to figure 1 but with smoothed isosurface.
Thanks
Diab Abueidda
2019년 9월 3일
Hi Walter,
I hope you have an idea of what I am trying to do. Please let me know if you have any ideas/suggestions. I have been stuck with this issue for a while, and your help is highly appreciated.
Thanks
채택된 답변
Thomas Satterly
2019년 9월 10일
If you're expecting the independant variables X, Y, and Z to make some nice looking 3D surface, you can use Delaunay Triangulation to make a best guess at what that surface would look like and set the corresponding vertex colors to a colormap scaled by dependant variable D. However, you have to be careful about extrapolating data between points using this approach, as the edges generated by triangulation are purely ficticious.
If there is no expected surface between the independant variables, I'd recommend using a 3D scatterplot of X, Y, and Z with the point colors or size determined by dependant variable D. This might be harder to visualizes than a surface, since there's not as strong of relational queues to nearby points, but it does eliminate some misleading extrapolation that generating a surface would cause.
댓글 수: 1
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Volume Visualization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)