You are on page 1of 14

%Abhishek Roy

%19MT10004
%Assignment 1B
%10
fprintf('QUESTION 10')
a=[((15^0.5)*(10^3)) 25/(14-6^2) log(35/0.4^3) (sin(65*pi/180)/cos(80*pi/180))
129 (cos(pi/20)^2)]
%Ans 1.0e+03 * [ 3.8730 -0.0011 0.0063 0.0052 0.1290 0.0010 ]
%11
fprintf('QUESTION 11')
x=0.85
y=12.5
a=[ y; y^x; log(y/x); x*y; x+y]
%12
fprintf('QUESTION 12')
vctC=[];
vctC(1)=5;
for i=2:12
vctC(i)=vctC(i-1)+4;
end
vctC
%a
Codd=[];
y=1;
for i=1:12
if mod(i,2)~=0
Codd(y)=vctC(i);
y=y+1;
end
end
Codd
%b
Ceven=[];
y=1;
for i=1:12
if mod(i,2)==0
Ceven(y)=vctC(i);
y=y+1;
end
end
Ceven
fprintf('QUESTION 13')
%13
vctD=[];
vctD(1)=0;
for i=2:10
vctD(i)=vctD(i-1)+3;
end
vctD
vct_Dop=[];
for i=1:10
vct_Dop(i)=vctD(11-i)

1
end
vct_Dop
fprintf('QUESTION 14')
%14
a=[3 9 -0.5 3.6 1.5 -0.8 4];
b=[12 -0.8 6 2 5 3 -7.4];
%a
vec=[a(3:6);a(4:7);b(2:5)];
vec
%b
vec=[a(2:7); b(1:3) b(5:7)];
vec=transpose(vec)
fprintf('QUESTION 15')
%15
A=[];
B=[];
A(1)=1.5;
B(1)=9.6;
for i=2:8
A(i)=A(i-1)+0.5;
B(i)=B(i-1)-0.5;
end
C=[A B]
D=reshape(C,[4,4]).'
%a
Da=[D(1,:) D(3,:)];
Da=reshape(Da, [8,1])
%b
Db=[D(:,2) D(:,4)]
Db=reshape(Db, [1,8])
%c
Dc=[D(1,1:2) D(2:4,2).' D(4,1:3)]
%16
fprintf('QUESTION 16')
vec=[1.5 2.5 3.5 4.5 5.5 6.6]
y=((vec+7).^4)./((vec+1).*(vec.^0.5))
%17
fprintf('QUESTION 17')
x=(pi/180)*[20 30 40 50 60 70]
y=(2*sin(x)+cos(x).^2)./(sin(x).^2)
%18
fprintf('QUESTION 18')
vec=[23.5 -17 6]
length1= (vec(1)^2+vec(2)^2+vec(3)^2)^0.5
length2=sqrt(sum(vec.^2))
%19
fprintf('QUESTION 19')
u=[7 -4 -11]
un=u./(sqrt(sum(u.^2)))
wL=(sqrt(sum(u.^2)))*un
%20
fprintf('QUESTION 20')
v=[8 6 4 2]
a=v./v

2
b=v.^-2
c=v.^-0.5
d=v-5
%21
fprintf('QUESTION 21')
o=[0 0 0];
a=[2 5 1];
b=[1 3 6];
c=[-6 8 2];
roa=a-o;
rob=b-o;
rac=c-a;
volume=dot(rob,(cross(roa,rac)))
%22
fprintf('QUESTION 22')
r1=[6 -3 2]
r2=[2 9 10]
theta=acosd(dot(r1,r2)/((dot(r1,r1)^0.5)*(dot(r2,r2)^0.5)))
%23
fprintf('QUESTION 23')
format long
e2=exp(2);
n=[5 10 50];
vec=[];
vec(1)=0;
%a
for i=2:n(1)+1
vec(i)=vec(i-1)+1;
end
vec
s=(2.^vec)./(factorial(vec))
sum(s)
%b
for i=2:n(2)+1
vec(i)=vec(i-1)+1;
end
vec
s=(2.^vec)./(factorial(vec))
sum(s)
%c
for i=2:n(3)+1
vec(i)=vec(i-1)+1;
end
vec
s=(2.^vec)./(factorial(vec))
sum(s)
%24
fprintf('QUESTION 24')
syms a b c d e
eqn1=2.5*a-b+3*c+1.5*d-2*e==57.1;
eqn2=3*a+4*b-2*c+2.5*d-e==27.6;
eqn3=-4*a+3*b+c-6*d+2*e==-81.2;
eqn4=2*a+3*b+c-2.5*d+4*e==-22.2;
eqn5=a+2*b+5*c-3*d+4*e==-12.2;

3
[A,B]=equationsToMatrix([eqn1,eqn2,eqn3,eqn4,eqn5],[a,b,c,d,e]);
X=linsolve(A,B)
%25
fprintf('QUESTION 25')
a=1.39;
b=0.0391;
R=0.08206;
T=300;
n=1;
Vs=[];
Vs(1)=0.1;
i=Vs(1);
j=2;
while i<=1
Vs(j)=Vs(j-1)+0.02;
i=i+0.02;
j=j+1;
end
P1=(n*R*T)./Vs;
P2=(n*R*T)./(Vs-n*b)-((n^2)*a)./Vs.^2;
percent_err=((P1-P2)./P2)*100;
[max_error,index]=max(percent_err);
max_error
vol=Vs(8)

QUESTION 10
a =

1.0e+03 *

Columns 1 through 3

3.872983346207417 -0.001136363636364 0.006304220257112

Columns 4 through 6

0.005219218532630 0.129000000000000 0.000975528258148

QUESTION 11
x =

0.850000000000000

y =

12.500000000000000

a =

12.500000000000000
8.558024216327803
2.688247573806030

4
10.625000000000000
13.350000000000000

QUESTION 12
vctC =

5 9 13 17 21 25 29 33 37 41 45 49

Codd =

5 13 21 29 37 45

Ceven =

9 17 25 33 41 49

QUESTION 13
vctD =

0 3 6 9 12 15 18 21 24 27

vct_Dop =

27

vct_Dop =

27 24

vct_Dop =

27 24 21

vct_Dop =

27 24 21 18

vct_Dop =

27 24 21 18 15

vct_Dop =

27 24 21 18 15 12

5
vct_Dop =

27 24 21 18 15 12 9

vct_Dop =

27 24 21 18 15 12 9 6

vct_Dop =

27 24 21 18 15 12 9 6 3

vct_Dop =

27 24 21 18 15 12 9 6 3 0

vct_Dop =

27 24 21 18 15 12 9 6 3 0

QUESTION 14
vec =

Columns 1 through 3

-0.500000000000000 3.600000000000000 1.500000000000000


3.600000000000000 1.500000000000000 -0.800000000000000
-0.800000000000000 6.000000000000000 2.000000000000000

Column 4

-0.800000000000000
4.000000000000000
5.000000000000000

vec =

9.000000000000000 12.000000000000000
-0.500000000000000 -0.800000000000000
3.600000000000000 6.000000000000000
1.500000000000000 5.000000000000000
-0.800000000000000 3.000000000000000
4.000000000000000 -7.400000000000000

QUESTION 15
C =

Columns 1 through 3

6
1.500000000000000 2.000000000000000 2.500000000000000

Columns 4 through 6

3.000000000000000 3.500000000000000 4.000000000000000

Columns 7 through 9

4.500000000000000 5.000000000000000 9.600000000000000

Columns 10 through 12

9.100000000000000 8.600000000000000 8.100000000000000

Columns 13 through 15

7.600000000000000 7.100000000000000 6.600000000000000

Column 16

6.100000000000000

D =

Columns 1 through 3

1.500000000000000 2.000000000000000 2.500000000000000


3.500000000000000 4.000000000000000 4.500000000000000
9.600000000000000 9.100000000000000 8.600000000000000
7.600000000000000 7.100000000000000 6.600000000000000

Column 4

3.000000000000000
5.000000000000000
8.100000000000000
6.100000000000000

Da =

1.500000000000000
2.000000000000000
2.500000000000000
3.000000000000000
9.600000000000000
9.100000000000000
8.600000000000000
8.100000000000000

Db =

7
2.000000000000000 3.000000000000000
4.000000000000000 5.000000000000000
9.100000000000000 8.100000000000000
7.100000000000000 6.100000000000000

Db =

Columns 1 through 3

2.000000000000000 4.000000000000000 9.100000000000000

Columns 4 through 6

7.100000000000000 3.000000000000000 5.000000000000000

Columns 7 through 8

8.100000000000000 6.100000000000000

Dc =

Columns 1 through 3

1.500000000000000 2.000000000000000 4.000000000000000

Columns 4 through 6

9.100000000000000 7.100000000000000 7.600000000000000

Columns 7 through 8

7.100000000000000 6.600000000000000

QUESTION 16
vec =

Columns 1 through 3

1.500000000000000 2.500000000000000 3.500000000000000

Columns 4 through 6

4.500000000000000 5.500000000000000 6.600000000000000

y =

1.0e+03 *

Columns 1 through 3

1.704865273391615 1.471825667681440 1.443812044121395

8
Columns 4 through 6

1.499071732985035 1.601567881277122 1.752145120075844

QUESTION 17
x =

Columns 1 through 3

0.349065850398866 0.523598775598299 0.698131700797732

Columns 4 through 6

0.872664625997165 1.047197551196598 1.221730476396031

y =

Columns 1 through 3

13.396240970739207 7.000000000000002 4.531724279182031

Columns 4 through 6

3.314902769706404 2.642734410091837 2.260829876383619

QUESTION 18
vec =

23.500000000000000 -17.000000000000000 6.000000000000000

length1 =

29.618406439239774

length2 =

29.618406439239774

QUESTION 19
u =

7 -4 -11

un =

0.513264902574737 -0.293294230042707 -0.806559132617443

wL =

9
7 -4 -11

QUESTION 20
v =

8 6 4 2

a =

1 1 1 1

b =

Columns 1 through 3

0.015625000000000 0.027777777777778 0.062500000000000

Column 4

0.250000000000000

c =

Columns 1 through 3

0.353553390593274 0.408248290463863 0.500000000000000

Column 4

0.707106781186547

d =

3 1 -1 -3

QUESTION 21
volume =

248

QUESTION 22
r1 =

6 -3 2

r2 =

2 9 10

10
theta =

86.989708479596544

QUESTION 23
vec =

0 1 2 3 4 5

s =

Columns 1 through 3

1.000000000000000 2.000000000000000 2.000000000000000

Columns 4 through 6

1.333333333333333 0.666666666666667 0.266666666666667

ans =

7.266666666666667

vec =

0 1 2 3 4 5 6 7 8 9 10

s =

Columns 1 through 3

1.000000000000000 2.000000000000000 2.000000000000000

Columns 4 through 6

1.333333333333333 0.666666666666667 0.266666666666667

Columns 7 through 9

0.088888888888889 0.025396825396825 0.006349206349206

Columns 10 through 11

0.001410934744268 0.000282186948854

ans =

11
7.388994708994708

vec =

Columns 1 through 13

0 1 2 3 4 5 6 7 8 9 10 11 12

Columns 14 through 26

13 14 15 16 17 18 19 20 21 22 23 24 25

Columns 27 through 39

26 27 28 29 30 31 32 33 34 35 36 37 38

Columns 40 through 51

39 40 41 42 43 44 45 46 47 48 49 50

s =

Columns 1 through 3

1.000000000000000 2.000000000000000 2.000000000000000

Columns 4 through 6

1.333333333333333 0.666666666666667 0.266666666666667

Columns 7 through 9

0.088888888888889 0.025396825396825 0.006349206349206

Columns 10 through 12

0.001410934744268 0.000282186948854 0.000051306717973

Columns 13 through 15

0.000008551119662 0.000001315556871 0.000000187936696

Columns 16 through 18

0.000000025058226 0.000000003132278 0.000000000368503

Columns 19 through 21

0.000000000040945 0.000000000004310 0.000000000000431

Columns 22 through 24

12
0.000000000000041 0.000000000000004 0.000000000000000

Columns 25 through 27

0.000000000000000 0.000000000000000 0.000000000000000

Columns 28 through 30

0.000000000000000 0.000000000000000 0.000000000000000

Columns 31 through 33

0.000000000000000 0.000000000000000 0.000000000000000

Columns 34 through 36

0.000000000000000 0.000000000000000 0.000000000000000

Columns 37 through 39

0.000000000000000 0.000000000000000 0.000000000000000

Columns 40 through 42

0.000000000000000 0.000000000000000 0.000000000000000

Columns 43 through 45

0.000000000000000 0.000000000000000 0.000000000000000

Columns 46 through 48

0.000000000000000 0.000000000000000 0.000000000000000

Columns 49 through 51

0.000000000000000 0.000000000000000 0.000000000000000

ans =

7.389056098930650

QUESTION 24
X =

41/5
-2
24/5
6
-28/5

QUESTION 25
max_error =

13
4.235860891868932

vol =

0.240000000000000

Published with MATLAB® R2021b

14

You might also like