Matlab Compiled
Matlab Compiled
INPUT-
clc
clear all
rv=[1 2 3 4 5] %row vector
cv=rv' %'-transpose
cv2=[1;2;3;4;5] %column vector
lrv=length(rv);
srv=size(rv);
A=[1 2 3;4 5 6;7 8 9]
dA=det(A)
rA=rank(A)
lA=tril(A)
uA=triu(A)
gA=diag(A)
B=[7 8 9;1 3 4;5 6 2]
C=A+B
D1=A*B %MATRIX MULTIPLICATION
D2=A.*B %CMOPONENT WISE MULTIPLICATION
E=inv(A) %INVERSE OF MATRIX A
size(A)
A(2,:)=[]
size(A)
OUTPUT-
rv =
1 2 3 4 5
cv =
3
4
cv2 =
A=
1 2 3
4 5 6
7 8 9
dA =
6.6613e-16
rA =
lA =
1 0 0
4 5 0
7 8 9
uA =
1 2 3
0 5 6
0 0 9
gA =
5
9
B=
7 8 9
1 3 4
5 6 2
C=
8 10 12
5 8 10
12 14 11
D1 =
24 32 23
63 83 68
7 16 27
4 15 24
35 48 18
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
1.541976e-18.
E=
1.0e+16 *
ans =
3 3
A=
1 2 3
7 8 9
ans =
2 3
Experiment 2
Input
%lab 2
%Title: PLOTTING OF CURVES AND SURFACES
%1. Parametric plot
clc
clear all
t=linspace(0,2*pi,20);
x=3+2*cos(t);
y=4+2*sin(t);
plot(x,y,'k-*')
axis equal
xlabel('x-Axis')
ylabel('y-Axis')
title('Graph of a circle with Centre(3,4) and Radius 2')
legend('(x-1)^2+(y-3)^2=4')
Output-
Input
%2.MULTIPLE PLOTS IN A FIGURE WINDOW(USNG COMMAND HOLD ON)
clc
clear 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)')
Output
Columns 91 through 99
Column 100
1.0000
Input
%exp 4
clc
clear all
x=0:0.1: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(3*x),'ms')
output
Columns 28 through 36
Columns 37 through 45
Columns 46 through 54
Input
OUTPUT-
Columns 91 through 99
0.9091 0.9192 0.9293 0.9394 0.9495 0.9596 0.9697 0.9798 0.9899
Column 100
1.0000
Experiment 3
Input
syms x real
f=x^3*(x-5)^2;
fx=diff(f,x);
fxx=diff(fx,x);
c=solve(fx)
c=double(c);
fprintf('There are %d critical points, and are shown
below.',length(c))
fprintf('\n\n')
disp(c(:))
cmin=min(c);cmax=max(c);
D=[cmin-0.2 cmax+0.2]
ezplot(f,D)
hold on
h=ezplot(fx,D)
set(h,'color','r')
e=ezplot(fxx,D)
set(e,'color','g')
legend('f','fx','fxx')
for i=1:length(c)
T1=subs(fxx,x,c(i));T1=double(T1);
T3=subs(f,x,c(i));T3=double(T3);
if(T1==0)
fprintf('\nThe inflection point is x=%d.',c(i))
fprintf('\nTestfails.')
elseif(T1<0)
fprintf('\nMaximum occurs at x=%d.',c(i))
fprintf('\nMaximum value is f(%d)=%d.',c(i),T3)
else
fprintf('\nMinimum point occurs at x=%d',c(i))
fprintf('\nMinimum value isf(%d)=%d.\n',c(i),T3)
end
plot(c(i),T3,'r*','markersize',15);
end
output-
c=
D=
-0.2000 5.2000
h=
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
e=
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
Testfails.
Testfails.
Input-
clc
clear
syms x
y1=input('ENTER THE UPPER CURVE AS A FUNCTION OF X:');
y2=input('ENTER THE LOWER CURVE AS A FUNTCION OF X:');
t=solve(y1-y2);t=double(t);
A=int(y1-y2,t(1),t(2))
D=[t(1)-0.2 t(2)+0.2];
ez1=ezplot(y1,D);
set(ez1,'color','r')
hold on
ez2=ezplot(y2,D);
legend('y1','y2')
xv=linspace(t(1),t(2));
y1v=subs(y1,x,xv);
y2v=subs(y2,x,xv);
x=[xv,xv];
y=[y1v,y2v];
fill(x,y,'g')
grid on
OUTPUT-
ENTER THE UPPER CURVE AS A FUNCTION OF X:x
A=
9/2
Q1) y=-x^2+4x
y=x^2
A=
8/3
Q2) y=7-2*x^2
y=x^2+4
A=
4
Experiment 6
Input-
clc
clear
syms t s
f=input('enter the function in terms of t:');
F=laplace(f)
OUTPUT-
1 -enter the function in terms of t:sin(t)
F=
1/(s^2 + 1)
F=
s/(s^2 + 25)
F=
a/(a^2 + s^2)
heaviside fn
Input-
clc
syms x
g1=x*(heaviside(x-0)-heaviside(x-1));
g2=(2-x)*(heaviside(x-1)-heaviside(x-2));
f=g1+g2;
F=laplace(f)
xv=linspace(0,2,100);
g1v=subs(g1,x,xv);
g2v=subs(g2,x,xv);
fv=subs(f,x,xv);
subplot(3,1,1)
plot(xv,g1v,'r.')
subplot(3,1,2)
plot(xv,g2v,'r.')
subplot(3,1,3)
plot(xv,fv,'r.')
output-
F=
clc
syms x
g1=sin(x)*(heaviside(x-0)-heaviside(x-2));
g2=cos(x)*(heaviside(x-2)-heaviside(x-4));
g3=x*(heaviside(x-4)-heaviside(x-6));
f=g1+g2+g3;
F=laplace(f)
xv=linspace(0,2,100);
g1v=subs(g1,x,xv);
g2v=subs(g2,x,xv);
g3v=subs(g3,x,xv);
fv=subs(f,x,xv);
subplot(4,4,1)
plot(xv,g1v,'r.')
subplot(4,4,2)
plot(xv,g2v,'r.')
subplot(4,4,3)
plot(xv,g3v,'r.')
subplot(4,4,4)
plot(xv,fv,'r.')
output-
F=
Output-
enter the period of the periodic function:2
sum =
(exp(-s)*(s + 1))/s^2 - 1/s^2 - (2*(exp(-s) - 1))/s
sum =
g=
g1 =
clc
syms x y m n
f=(x^3-y)/(x^3+y);
lp=[0 0];
x0=lp(1);
y0=lp(2);
L1=limit(limit(f,x,x0),y,y0)
L2=limit(limit(f,y,y0),x,x0)
y=m*x^3-x
fx=subs(f);fx=simplify(fx);
L3=limit(fx,x,x0)
output-
L1 =
-1
L2 =
y=
m*x^3 - x
L3 =
-1
Experiment 8
Input-
end
end
end
Output-
fx = 4*x^3 - 4*y
fy = 4*y^3 - 4*x
fxx = 12*x^2
fyy = 12*y^2
fxy = -4
d = 144*x^2*y^2 - 16
cx =
-1
cy =
-1
1
function has a saddle point at(0,0).
(0,0)=-16
ans =
ans =
ans =
ans =