필터 지우기
필터 지우기

How to plot function with conditions (3d)

조회 수: 4 (최근 30일)
Niklas Kurz
Niklas Kurz 2020년 12월 6일
댓글: Niklas Kurz 2020년 12월 6일
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일
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개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by