How to plot a triangular shape function on a triangular domain?
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Soroush Asarzadeh
le 25 Avr 2016
Commenté : Soroush Asarzadeh
le 27 Avr 2016
Hello, I want to plot the following shape function: N(s,t)=t*(2*t-1) It has to look like the following diagramm:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162483/image.jpeg)
but I get this one:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/162485/image.jpeg)
Here is my code:
[s,t]=meshgrid(0:0.1:1,0:0.1:1)
N3=@(s,t)t.*(2*t-1);
surf(s,t,N3(s,t))
I know that the problem is with the rectangular domain, that meshgrid generates. But I don't know how to define a triangular domain. Has anybody an idea?
Thanks
0 commentaires
Réponse acceptée
Mike Garrity
le 25 Avr 2016
3 commentaires
Mike Garrity
le 26 Avr 2016
I think that passing a function handle into surf is making things more complicated than you really need.
I don't know what N3 is, but using the N from the top, I get this:
[s,t] = meshgrid(0:0.025:1);
z = t.*(2*t-1);
z(s+t > 1) = nan;
surf(s,t,z)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/183670/image.png)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!