Contour plot of concave shape from 3 vectors coordinates

1 次查看(过去 30 天)
Hello,
I'm analyzing a membrane with FEM. The membrane has a rectangular shape with a hole at the center so I've only modeled a quarter of the whole membrane using 60 nodes like in the first image.
I also performed the stress recovery and I have the data arranged in a [Nx3] matrix 'Sxx' , where:
Sxx(:,1) = x coordinate of the node
Sxx(:,2) = y coordinate of the node
Sxx(:,3) = magnitude of the stress
I am trying to make a contour plot of the stress, but due to the hole at the center, the shape is concave and griddata seems to interpolate also across the hole, producing a straight line instead of a quarter of a circle.
This is the code i'm using:
xv1 = min(Sxx(:,1)):max(Sxx(:,1));
yv1 = min(Sxx(:,2)):max(Sxx(:,2));
[X1,Y1] = ndgrid(xv1,yv1);
Z1 = griddata(Sxx(:,1) , Sxx(:,2) , Sxx(:,3) , X1 , Y1);
h1 = pcolor(X1,Y1,Z1);
title('\sigma_{xx}')
c1 = colorbar;
c1.Label.String = '[N/mm^2]';
I also tried every interpolation method of griddata but still doesn't work. All i keep getting is the second image.
I searched online if there's any possibility of limiting the interpolation between points to a certain range but i couldn't find anything that works for me.
I can't transform the stress vector into a matrix due to irregular distances between nodes.
Thank you
  3 个评论
chicken vector
chicken vector 2020-6-9
编辑:chicken vector 2020-6-9
This is Z1 at the lower left corner
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN 87.3888 81.0505 74.7122 68.3739 62.0356
NaN NaN NaN NaN NaN NaN NaN NaN NaN 83.7098 85.1843 78.8460 72.5077 66.1694 59.8311
NaN NaN NaN NaN NaN NaN NaN NaN 80.0308 80.6615 82.9798 76.6415 70.3032 63.9649 58.2034
NaN NaN NaN NaN NaN NaN NaN 76.3518 76.2562 78.3393 80.7753 74.4370 68.0987 62.7671 57.5601
NaN NaN NaN NaN NaN NaN 72.6728 72.5673 73.9341 76.0172 78.5708 72.5377 67.3307 62.1238 56.9168
NaN NaN NaN NaN NaN 68.9938 68.8883 69.5289 71.6120 73.6950 77.1014 71.8944 66.6875 61.4805 56.2735
NaN NaN NaN NaN 65.3148 65.2093 65.1236 67.2067 69.2898 73.1976 72.0822 68.2124 64.3425 60.4727 55.6302
NaN NaN NaN 61.6358 61.5303 61.4248 62.8015 64.8846 66.9677 70.8392 66.9694 63.0995 59.2297 55.3599 51.4900
NaN NaN 57.9568 57.8513 57.7458 58.3963 60.4794 62.5624 64.6455 65.7263 61.8565 57.9867 54.1168 50.9474 48.4328
NaN 54.2778 54.1723 54.0668 53.9910 56.0741 58.1572 60.2403 62.3234 60.6135 57.1716 54.6570 52.1425 49.6279 47.1134
50.5987 50.4932 50.3877 50.2822 51.6689 53.7520 55.8351 57.9182 59.0665 58.3667 55.8521 53.3376 50.8230 48.3085 45.7939
46.8142 46.7087 46.6032 47.2637 49.3467 51.4298 53.5129 54
I thought that griddata was interpolating between the two points (0,25) and (25,0), creating a straight line. This seems clear by taking a look at the values on the diagonal between these two points, which increase a constant rate.
If I use 'shading interp' it just removes the black gridlines but the plot still has the straight line.
I'm sure calculations are good so it doesn't really matter, it's just for aesthetics, but i really can't understand how to solve this.

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2020-6-9
To make the plot look neater, you have to increase the number of discretizations.
m = 100 ; n = 100 ; % can be changed
xv1 = linspace(min(Sxx(:,1)),max(Sxx(:,1)),m);
yv1 = linspace(min(Sxx(:,2)),max(Sxx(:,2)),n);
[X1,Y1] = meshgrid(xv1,yv1);
Z1 = griddata(Sxx(:,1) , Sxx(:,2) , Sxx(:,3) , X1 , Y1);
h1 = pcolor(X1,Y1,Z1);
shading interp
title('\sigma_{xx}')
c1 = colorbar;
c1.Label.String = '[N/mm^2]';
  6 个评论
chicken vector
chicken vector 2020-6-9
Right now I solved the problem with this function:
but it's not a very clean approach so i will certainly look deeper into inpolygon.
Thanks for all your help.
Best regards
KSSV
KSSV 2020-6-9
Hey....I strictly suggest you inpolygon. This is very easy to use.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by