# How to plot a shape function of triangular element with 3 nodes ?

14 views (last 30 days)
Ehsan Kowsari on 24 Apr 2019
Answered: Mark Schoen on 15 Oct 2019
Hi guys
I want to plot a shape function of triangular element with its equations in matlab but I can't find a way to plot a triangular area with 3 equation
I know that we can plot it with 3 points but I want to plot it with its equations of shape functions similar to below picture :

Mark Schoen on 15 Oct 2019
The best way to approach plotting a filled polygonal region is to use the "patch" function,
which requires the (x,y,z) coordinates of each vertex of the shape.
For a triangle, you have three equations, each corresponding to one side, so your three vertices will be given by the intersection points between different pairs of lines. To calculate intersection points, use the "solve" function. For an example of how to use "solve" on a system of two equations, type the following into the MATLAB Command Window:
>> openExample('symbolic/SolveMultivariateEquationsAndAssignOutputsToVariablesExample')
Also, once you have plotted the 3 vertices with "patch", use the command "view(3)" to see the plot in three dimensions.

### Categories

Find more on Surface and Mesh Plots in Help Center and File Exchange

R2017a

### Community Treasure Hunt

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

Start Hunting!