Plot surface data which satisfies x/y condition

12 ビュー (過去 30 日間)
leonidas86
leonidas86 2020 年 5 月 5 日
回答済み: KSSV 2020 年 5 月 5 日
Hello,
I have a function g(x,y). I want to plot the surf data only for areas where condition x + y = 5 is satisfied. How can I do this?
My code so far:
g = matlabFunction(f1);
[x y]=meshgrid(brk,brk);
data = g(x,y);
figure(1)
surf(x,y,data)

回答 (1 件)

KSSV
KSSV 2020 年 5 月 5 日
x = -10:1:10 ;
y = -10:1:10 ;
[X,Y] = meshgrid(x,y) ;
idx = X+Y==5 ;
Z = double(idx) ;
surf(X,Y,Z)
shading interp
colorbar

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by