現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
3D plot help
2 ビュー (過去 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,
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
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)