contour plots on a given geometry - finite element
Show older comments
I have some values of stretch that I need to assign to a given set of elements and then I want to show a contour plot of those values on the geometry that I get by plotting the elements through the nodes. How can I do?
3 Comments
Mathieu NOE
on 7 Jun 2024
so I guessed it is a 2D problem
your geometry is defined by x,y data and your stretch data can be used as z values
if you have those x,y,z data as vectors (scattered data) then you can use this method to create your contour plot
Federica
on 8 Jun 2024
Mathieu NOE
on 10 Jun 2024
can you share the data ?
Answers (1)
Hi Federica,
I understand that you have n-values for both stretch and corresponding centroids and wish to create a contour plot for the available data.
Following steps might be useful to achieve the required plot:
- Create a grid that covers the range of the centroid coordinates:
[X, Y] = meshgrid(centroid(x),centroid(y));
2. Create the Contour Plot using “contour” function:
contour(X, Y, corresponding values);
Here is an example code for plotting contour plot:
centroid = [linspace(-2*pi,2*pi); linspace(0,4*pi)]';
[X1,Y1] = meshgrid(centroid(:,1),centroid(:,2));
stretch = sin(X1)+ cos(Y1);
contour(X1,Y1,stretch)
For more information related to contour plot please refer the shared MATLAB documentation link: https://www.mathworks.com/help/matlab/ref/contour.html
Hope this helps.
Categories
Find more on Contour Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!