Wednesday, March 4, 2009

symbolic toolbox matlab

today install the symbolic toolbox.

=========

% here is a example to plot scalar field with surface and contour
% also the gradient and others
clear;
close all;

% another scalar field
[X,Y] = meshgrid(-15:.5:15, -10:.5:10);
Z = 5.0 * exp(-X.^2/90 - Y.^2/25);

%surface of Z(X,Y)
figure,surf(X,Y,Z),colorbar,axis equal

%contour
figure,
[c,h] = contour(X,Y,Z); clabel(c,h), colorbar,axis equal

%gradient
[px,py] = gradient(Z,.2,.15);
figure,
[c,h] = contour(X,Y,Z); colorbar,axis equal,hold on
%QUIVER(X,Y,U,V) plots velocity vectors as arrows with components (u,v)
% at the points (x,y).
quiver(X,Y,px,py), hold off, axis image

No comments: