フィルターのクリア

How to use contourf to plot a mesh not generated in matlab, i.e. imported mesh coordinates from abaqus. The issue is that coordinates are not sequential.

28 ビュー (過去 30 日間)
I'm trying to use contourf with x and y coordinates being random or non sequential. I have z value for each X y coordinate. Normaly we would create a rectangular mesh and then fill up the z values. Here the issue is that the geometry is meshed in abaqus and the mesh nodes and element related information is fed to my code. Now the nodes are not sequential matrix.

回答 (2 件)

Star Strider
Star Strider 2024 年 7 月 7 日 21:09
It would help tto have your data.
Since there are (x,y,z) coordinates (there can be duplicates), I would use the scatteredInterpolant function to create an interpolant, and then use either ndgrid or meshgrid tto create the relevant argument matrices using the ‘x’and ‘y’.vectors to define them.
There are several examples on MATLAB Answers using that approach, that create column vectors for ‘x’, ‘y’ and ‘z’ to use with scatteredInterpolant,.and then generate the ‘z’ matrix from the argument matrices. Then use surf or surfc to plot them.
.
  4 件のコメント
Star Strider
Star Strider 2024 年 7 月 8 日 12:46
This sort of works, however it takes 605.3 seconds to complete and about as much time to render the surface plots. It fails, because it fills (interpolates) the voids areas. I do not see any way to correct for that.
imshow(imread('boundary conditions.jpg'))
LD = load('plotdata.mat');
plot = LD.plot;
x = plot(:,1);
y = plot(:,2);
z = plot(:,3);
figure
scatter3(x, y, z, 5, z, 'filled')
colormap(turbo)
% return
tic
xv = linspace(min(x), max(x), size(plot,1));
yv = linspace(min(y), max(y), size(plot,1));
F = scatteredInterpolant(x, y, z);
[X,Y] = ndgrid(xv, yv);
Z = F(X,Y);
figure
surfc(X, Y, Z, 'EdgeColor','none')
T = delaunay(X, Y);
figure
trisurf(T, X, Y, Z, 'EdgeColor','k', 'LineWidth',0.2)
toc
This also ended up crashing my computer.
.
Subham Prasad
Subham Prasad 2024 年 7 月 9 日 5:50
Thank you for the answer. The scatter plot (2D) will do for now. I think contourf kind of plot is not possible in this case due to the randomness of data. Had it been a sequential set of data points it would have worked. Do let me know if you find any way to get contour plot kind of image. I am attaching an example of how the plot should have looked and also one image to show how it looks with scatter plot (2D).

サインインしてコメントする。


Walter Roberson
Walter Roberson 2024 年 7 月 7 日 19:56
編集済み: Walter Roberson 2024 年 7 月 7 日 20:02
  2 件のコメント
Subham Prasad
Subham Prasad 2024 年 7 月 8 日 3:46
I have used 4 noded quad element for meshing. The nodal coordinates are in that way.
Subham Prasad
Subham Prasad 2024 年 7 月 8 日 9:48
These are good for triangular elements, is there any similar funtion for quad element?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by