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 ?

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 12월 6일

0 개 추천

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)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

제품

태그

질문:

2020년 12월 6일

댓글:

2020년 12월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by