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 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!