0% found this document useful (0 votes)
9 views8 pages

Experiment 10

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views8 pages

Experiment 10

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Experiment 10

Part 1(Plot the vector field of xi+yj):-


Code:-
clc

clear all

syms x y

F=input('enter the function as i and j order in vector form:');

P=inline(vectorize(F(1)),'x','y');

Q=inline(vectorize(F(2)),'x','y');

X=linspace(-1,1,10);

Y=X;

[X,Y]=meshgrid(X,Y);

U=P(X,Y);

V=Q(X,Y);

quiver(X,Y,U,V,1)

axis on

xlabel('x')

ylabel('y')
Output:-

Part 1(plot the vector field of 3+xi+4+yj):-


Part 1(plot the vector field 7x+2i+3y+4j):-

Part 2 (Draw the 3-D vector field xi-yj+zk):-


Code:-
%draw the 3-D vector field xi-yj+zk

clc

clear all

syms x y z

F=input('enter the function as i,j and k order in vector form:');

P=inline(vectorize(F(1)),'x','y','z');

Q=inline(vectorize(F(2)),'x','y','z');

R=inline(vectorize(F(3)),'x','y','z');

x=linspace(-1,1,5);

y=x;

z=x;

[X,Y,Z]=meshgrid(x,y,z);
U=P(X,Y,Z);

V=Q(X,Y,Z);

W=R(X,Y,Z);

quiver3(X,Y,Z,U,V,W,1.5)

axis on

xlabel('x')

ylabel('y')

zlabel('z')

Output:-

Part 3 (Find the gradient of vector field of f(x,y)=x^2*y-


y^3 Plot the gradient vector field together with a
contour map of f. How are they related?):-
Code:-
%find the gradient of vector field of f(x,y)=x^2*y-y^3 Plot the gradient

%vector field together with a contour map of f.How are the y related?

clc

clear all
syms x y

f=input('enter the function f(x,y):');

F=gradient(f)

P=inline(vectorize(F(1)),'x','y');

Q=inline(vectorize(F(2)),'x','y');

x=linspace(-2,2,10);

y=x;

[X,Y]=meshgrid(x,y);

U=P(X,Y);

V=Q(X,Y);

quiver(X,Y,U,V,1)

axis on

xlabel('x')

ylabel('y')

hold on

ezcontour(f,[-2 2])

%the gradient vectors are orthogonal to the contour


Output:-

Part 4 (Find the (a)the curl and (b)the divergence of the


vector field. F(x,y,z)=x^2*y*zi+x*y^2*zj+x*y*z^2k

Code:-

clc

clear all

syms x y z

F=input('enter the vector as i,j and k order in vector form:')

curl_F=curl(F,[x,y,z])

div_F=divergence(F,[x,y,z])
Output:-

Part 5 (Determine whether or not the vector field


F(x,y,z) = y^2*z^3i + 2*x*y*z^3j + 3*x*y^2*z^2k is
conservative or not):-
Code:-
clc

clear all

syms x y z real

F = input('Enter the vector as i, j and k order in vector form : ');

curl_f = curl(F, [x y z])

if (curl_f == [0 0 0])

f = potential(F, [x y z])
else

sprintf('curl_F is not equal to zero')

end

Output:-

You might also like