如何用画f(x)=(x2-x1)^2+(1-x1)^2 图形?用matlab。

如题所述

x1=0:0.1:1;
x2=0:0.1:1;
[x1,x2]=meshgrid(x1,x2);
y=(x2-x1).^2+(1-x1).^2;
surf(x1,x2,y)
shading flat
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-10-11
syms x1 x2
f=(x2-x1)^2+(1-x1)^2;
ezmesh(f)