1. 程式人生 > >matlab向量場生成

matlab向量場生成

figure
[X,Y] =meshgrid(-2:.2:2);
Z = (Y-X);                   %速度向量 會確定方向
[DX,DY] = gradient(Z,.2,.2);


hold on 
quiver(X,Y,DX,DY)
colormap hsv

hold off


[x,y,z] = peaks(20);
[DX,DY] = gradient(z,0.1,0.1);
quiver(x,y,DX,DY)