30 likes | 210 Views
Problems and solutions Session 5. Problems. Draw the contour plot of function F(x,y) = x 1.5 y 2 exp(-(x-2)-(y-0.5)) on [0,5]x[0,5] and its gradient field with quiver command in the same picture. Use meshgrid to create the X,Y –grid.
E N D
Problems • Draw the contour plot of function F(x,y) = x1.5y2exp(-(x-2)-(y-0.5)) on [0,5]x[0,5] and its gradient field with quiver command in the same picture. • Use meshgrid to create the X,Y –grid. • Compute the derivative by hand or by using your earlier differf.m function. • Make a histogram of points randn(10000,1). Introduction to MATLAB - Solutions 5
x = 0:.25:5; % negative x gives complex values, so change the domain [X,Y] = meshgrid(x,x); expterm = @(X,Y) exp(-(X-2)-(Y-0.5)); FXY = X.^1.5.*Y.^2.*expterm(X,Y); dxFXY = 1.5*sqrt(X).*Y.^2.*expterm(X,Y)- FXY; dyFXY = 2*X.^1.5.*Y.*expterm(X,Y)-FXY; contour(X,Y,FXY) hold on quiver(X,Y,dxFXY,dyFXY) hold off hist(randn(10000,1),50) Some solutions Introduction to MATLAB - Solutions 5