Professional Documents
Culture Documents
clc
clear all
close all
x=linspace(0,1);
plot(x,x.^2,'r')
hold on
plot(x,sin(x),'g.')
plot(x,exp(x),'m+')
legend('x^2','sin(x)','exp(x)')
Experiment-2
clc
clear all
close all
x=0:0.01:2*pi;
subplot(2,2,1)
plot(x, sin(x));
subplot(2,2,2)
plot(x, cos(x), 'r-*');
subplot(2,2,3)
plot(x, exp(-x), 'go');
subplot(2,2,4)
plot(x, sin(x), 'ms');
Experiment-3
clc
clear all
close all
syms x
f=sin(2*x)+cos(3*x);
figure(1);
ezplot(f);
figure(2);
ezplot(f, [0,3]);
Experiment-4
clc
clear all
close all
syms x
D=[x1-2, x1+2];
ezplot(y, D);
hold on
yd = diff(y, x);
slope = subs(yd, x, x1);
y1=subs(y,x,x1);
Tangent=slope*(x-x1)+y1;
Line=ezplot(Tangent, D);
clc
clear all
close all
y=linspace(-10,10,1000);
plot(y,cos(y),'b',y,cos(2*y),'g.');
xlabel('x axis');
ylabel('y axis');
legend('cos(x).cos(2x)','location','northeast')
Experiment-6
clc
clear all
close all
t=linspace(0,2*pi,500);
x=cos(t);
y=sin(t);
z=sin(5*t);
comet3(x,y,z)
plot3(x,y,z,'g*','markersize',7)
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')
title('3D Curve')
Experiment-7
clc
clear all
close all
syms x y;
f=2*(x^2+y^2);
ezsurf(f);
colormap winter;
Experiment-8
clc
clear all
close all
x=-1:0.5:1;
y=-1:0.5:1;
[x,y] = meshgrid(x,y);
z = x.*y.^2-x.^3;
surf(x,y,z);
colormap spring;
shading interp;
Experiment-9
clc
clear all
close all
syms x real
fx=diff(f,x);
fxx=diff(fx,x);
ezplot(f);
hold on
D=[0,5];
L1=ezplot(f, D);
set(L1, "color", "b");
hold on
L2=ezplot(fx, D);
set(L2, "color", "r");
L3=ezplot(fxx, D);
set(L3, "color", "g");
clc
clear all
close all
syms x real;
fx=diff(f);
fxx=diff(fx);
c=solve(fx);
c=double(c);
for i=1:length(c)
T1=subs(fxx, x, c(i));
T1=double(T1);
T3=subs(f, x, c(i));
if (T1==0)
else
if (T1<0)
else
end
end
cmin=min(c);
cmax=max(c);
D=[cmin-2, cmax+2];
ezplot(f,D);
hold on
end
Experiment-11
clc
clear all
close all
syms x y real;
t=solve(y1-y2);
B=double(t);
n=length(B);
m1=min(B);
m2=max(B);
hold on;
Ta=0;
for i=1:n-1
xx=[x1, fliplr(x1)];
yy=[yy1, fliplr(yy2)];
end
hold on
Experiment-12
clc
clear all
close all
syms x;
fx=inline(vectorize(f));
xivals=linspace(iL(1),iL(2),201);
[X,Y,Z]=cylinder(fx(xivals)-yr,100);
figure('Position',[700 200 560 420])
z=iL(1)+Z.*(iL(2)-iL(1));
surf(Z,Y+yr,X,'EdgeColor','none','FaceColor','flat','FaceAlpha',0.6);
hold on;
clc
clear all
close all
clearvars
syms x y L;
F=f+L*g;
x1=double(x1);
y1=double(y1);
xmx=max(x1); xmn=min(x1);
ymx=max(y1); ymn=min(y1);
tmp=get(h, "contourMatrix");
xdt=tmp(1, 2:end);
ydt=tmp(2, 2:end);
zdt=double(subs(f, {x, y}, {xdt, ydt}));
for i=1:numel(x1)
end
title("Constrained Maxima/Minima")
display(double(G));
Experiment-14
clc
clear all
close all
clearvars;
syms x y z L;
F=f+L*g;
Z=double([x1 y1 z1]);
Dup=subs(f, x, Z(1,1));
Dup=subs(Dup, y, Z(1,2));
Dup=subs(Dup, z, Z(1,3));
Dup=subs(f, x, Z(2,1));
Dup=subs(Dup, y, Z(2,2));
Dup=subs(Dup, z, Z(2,3));
clc
clear all
close all
clearvars
syms x y L;
f=(x^2)*(y^2);
g=2*x+4*y-40;
F=f+L*g;
Z=double([x1 y1]);
Max=1e10;
[rows, cols]=size(Z);
for i=1:rows
Dup=subs(f, x, Z(i,1));
Dup=subs(Dup, y, Z(i,2));
Dup=double(Dup);
if Dup>Max
Max=Dup;
end
end
clc
clear all
close all
syms x y z
syms x y z
clc
clear all
close all
syms x y z
%Find the Volume of the Region Enclosed by the surfaces z=x^2+3y^2 and
%z=8-x^2-y^2
clc
clear all
close all
syms x y z;
xa=-2;
xb=2;
ya=-sqrt(2-x^2/2);
yb=sqrt(2-x^2/2);
za=x^2+3*y^2;
zb=8-x^2-y^2;
%Find the Volume of the Region Enclosed by the surfaces z=0 and x+z=3. The
%Limits of Integration are z=0 to 3, x=-sqrt(4-y) to sqrt(4-y) and y=-2 to
%2
clc
clear all
close all
syms x y z;
xa=-sqrt(4-y^2);
xb=sqrt(4-y^2);
ya=-2;
yb=2;
za=0+0*x+0*y;
zb=3-x-0*y;
%Find the Volume of the Region Enclosed by the surfaces z=0 and x+z=3. The
%Limits of Integration are z=0 to 3, x=-sqrt(4-y) to sqrt(4-y) and y=-2 to
%2
clc
clear all
close all
syms x y z real;
xa=0;
xb=1;
ya=0+0*x;
yb=1-x;
za=0*x+0*y;
zb=cos(pi*x/2)+0*y;
clc
clear all
close all
syms x y
P(x,y)=grad(1); Q(x,y)=grad(2);
quiver(X, Y, U, V, 1);
axis on;
xlabel('x'); ylabel('y');
hold on;
fcontour(f, [-2, 2]);
Experiment-23
clc
clear all
close all
syms x y
x=linspace(-4, 4, 20);y=x;
figure
pcolor(X, Y, div(X, Y));
shading interp;
hold on;
quiver(X, Y, U, V, 1);
axis on;
hold off;
clc
clear all
close all
syms x y z
f=input("Enter the 3D Vector Function in the form [f1, f2, f3] :");
figure;
subplot(1, 2, 1);
quiver3(X, Y, Z, U, V, W);
title("3-D view of Vector Field");
subplot(1, 2, 2);
quiver3(X, Y, Z, CR1, CR2, CR3);
title("3-D view of a Curl")
Experiment-25
clc
clear all
close all
syms x y t
a=I(1); b=I(2);
dr=diff(r, t);
F=subs(f, {x, y}, r);
Fdr=sum(F.*dr);
I=int(Fdr, t, a, b);
quiver(X, Y, U, V, 1.5);
hold on
t1=linspace(0, 2*pi);
x=subs(r(1), t1); y=subs(r(2), t1);
plot(x, y, "r");
Experiment-26
clc
clear all
close all
syms x y z t
a=I(1); b=I(2);
dr=diff(r, t);
F=subs(f, {x, y, z}, r);
Fdr=sum(F.*dr);
I=int(Fdr, t, a, b);
quiver3(X, Y, Z, U, V, W, 1.5);
hold on
t1=linspace(0, 1, 10);
x=subs(r(1), t1); y=subs(r(2), t1); z=subs(r(3), t1);
plot3(x, y, z, "r");
Experiment-27
clc
clear all
close all
syms x y r t;
U=P(X, Y);
V=Q(X, Y);
quiver(X, Y, U, V);
hold on
clc
clear all
close all
syms x y r t;
U=P(X, Y);
V=Q(X, Y);
quiver(X, Y, U, V);
hold on