How to plot function with conditions (3d)
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Niklas Kurz
il 6 Dic 2020
Commentato: Niklas Kurz
il 6 Dic 2020
Suppose I want to plot the function
% f(x,y) = x.*y by saying:
[x,y] = meshgrid (-2:2:2);
z = x.*y;
surf(x,y,z)
But what if I want the x and y values also to fulfill the equation x + y <= 1 ?
0 Commenti
Risposta accettata
Ameer Hamza
il 6 Dic 2020
You can replace the unwanted values with nan.
[x,y] = meshgrid (-2:2:2);
z = x.*y;
mask = x + y <= 1;
z(~mask) = nan;
surf(x,y,z)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Lighting, Transparency, and Shading in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!