Contour plot of concave shape from 3 vectors coordinates
1 view (last 30 days)
Show older comments
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 Comments
Accepted Answer
KSSV
on 9 Jun 2020
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 Comments
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!