function y=fun(x) y=1./((x-2).^2+0.1)+1./((x-3).^4+0.01); end ----------------------------------------- fun(a) ans = 0.9716 0.0023 100.9091 1.2340
----------------------------------------
函数句柄
ff=@(x)1./((x-2).^2+0.1)+1./((x-3).^4+0.01);
ff(a)
ans =
0.9716 0.0023
100.9091 1.2340
注意[A,B]=meshgrid(a,b);
x=-pi/2:0.001:pi/2; y1=sqrt(cos(x)); a=-2:0.1:2; b=-4:0.1:4; [A,B]=meshgrid(a,b); y2=(A.^2)/4+(B.^2)/16; subplot(2,2,2); plot(x,y1); subplot(2,2,3); mesh(A,B,y2);