Embed presentation
Download to read offline

![Program Code on MATLAB
% PAF-KIET
% Salman Khaliq 3746
% Assignment # 1
% Example of Scalar Gradient Field- 2D Graph
close all; clear;
x = -2:.2:2; y = -1:.2:1;
[xx,yy] = meshgrid(x,y);
s = xx.*exp(-xx.^2-yy.^2);
figure(1);surf(x,y,s);shading interp;
rotate3d;
xlabel('x');ylabel('y');zlabel('s');
title('2-D space varying scalar field: s = x e^{-(x^2+y^2)}');
pause;
[px,py] = gradient(s,.2,.2);
figure(2);quiver(x,y,px,py,2);
xlabel('x');ylabel('y');
title('Gradient of the scalar field: nablas=(1-2x^2)e^{-(x^2+y^2)} {bf x}
- 2xye^{-(x^2+y^2)} {bf y}');](https://image.slidesharecdn.com/aem-120520121633-phpapp01/85/Aem-2-320.jpg)


This document contains a MATLAB program code for an assignment submitted by Salman Khaliq Bajwa (ID: 3746) for the course AEM (CId: 10447). The program generates a 2D graph of a scalar gradient field and plots the gradient of the scalar field using functions like meshgrid, surf, quiver, and gradient.

![Program Code on MATLAB
% PAF-KIET
% Salman Khaliq 3746
% Assignment # 1
% Example of Scalar Gradient Field- 2D Graph
close all; clear;
x = -2:.2:2; y = -1:.2:1;
[xx,yy] = meshgrid(x,y);
s = xx.*exp(-xx.^2-yy.^2);
figure(1);surf(x,y,s);shading interp;
rotate3d;
xlabel('x');ylabel('y');zlabel('s');
title('2-D space varying scalar field: s = x e^{-(x^2+y^2)}');
pause;
[px,py] = gradient(s,.2,.2);
figure(2);quiver(x,y,px,py,2);
xlabel('x');ylabel('y');
title('Gradient of the scalar field: nablas=(1-2x^2)e^{-(x^2+y^2)} {bf x}
- 2xye^{-(x^2+y^2)} {bf y}');](https://image.slidesharecdn.com/aem-120520121633-phpapp01/85/Aem-2-320.jpg)
