matlab图像导数求积分_matlab微积分问题:导数、偏导数

1.函数的导数和高阶导数,可用diff()函数

y=diff(fun, x)求导数

y=diff(fun, x, n)求n阶导数

例:求函数f(x)=sinx/(x2+4x+3)的4阶导数

解:>>syms x; f=sin(x)/(x^2+4*x+3); f1=diff(f,x,4)

f1 =

sin(x)/(x^2+4*x+3)+4*cos(x)/(x^2+4*x+3)^2*(2*x+4)-12*sin(x)/(x^2+4*x+3)^3*(2*x+4)^2+12*sin(x)/(x^2+4*x+3)^2-24*cos(x)/(x^2+4*x+3)^4*(2*x+4)^3+48*cos(x)/(x^2+4*x+3)^3*(2*x+4)+24*sin(x)/(x^2+4*x+3)^5*(2*x+4)^4-72*sin(x)/(x^2+4*x+3)^4*(2*x+4)^2+24*sin(x)/(x^2+4*x+3)^3

2.多元函数的偏导数:已知f(x,y),求,则可如此求得

f=diff(diff(f,x,m),y,n),或f=diff(diff(f,y,n),x,m)

例:求z=f(x,y)=的偏导数,并用图形表示

解:>> syms x y

z=(x^2-2*x)*exp(-x^2-y^2-x*y);

zx=simple(diff(z,x))

zx =

-exp(-x^2-y^2-x*y)*(-2*x+2+2*x^3+x^2*y-4*x^2-2*x*y)

>>zy=diff(z,y)

zy =

(x^2-2*x)*(-2*y-x)*exp(-x^2-y^2-x*y)

在x,区域生成网格,则可绘制原函数的三位曲面:

>>[x,y]=meshgrid(-3:.2:3,-2:.2:2);

>>z=(x.^2-2*x).*exp(-x.^2-y.^2-x.*y);

>>surf(x,y,z),axis([-3 3 -2 2 -0.7 1.5])

既然计算出对两个自变量的一阶偏导数,则可以调用quiver()函数绘制出引力线,该引力线可以叠印在以contour()函数绘制出的等值线:

>>contour(x,y,z,30),hold on %绘制等值线

>>zx=-exp(-x.^2-y.^2-x.*y).*(-2*x+2+2*x.^3+x.^2.*y-4*x.^2-2*x.*y);

>>zy=-x.*(x-2).*(2*y+x).*exp(-x.^2-y.^2-x.*y);

>>quiver(x,y,zx,zy) %绘制引力线

例:已知,求

解:>> syms x y z;f=sin(x^2*y)*exp(-x^2*y-z^2);

>>df=diff(diff(diff(f,x,2),y),z);df=simple(df)

df =

-4*z*exp(-x^2*y-z^2)*(cos(x^2*y)-10*cos(x^2*y)*y*x^2+4*sin(x^2*y)*x^4*y^2+4*cos(x^2*y)*x^4*y^2-sin(x^2*y))

你可能感兴趣的:(matlab图像导数求积分)