NA LAB (Matlab Assignment 01)
NA LAB (Matlab Assignment 01)
Chapter 01:
Q13 (a):
>> x=12;
>> z=tand(4*x)
z=
1.110612514829193
>> y=(4*tand(x)-4*tand(x)^3)/(1-6*tand(x)^2+tand(x)^4)
y=
1.110612514829193
As z=y (Hence given Identity proved)
Q13 (b):
>> x=12
x=
12
>> y=sind(12)^3
y=
0.008987455040201
>> z=(1/4)*(3*sind(x)-sind(3*x))
z=
0.008987455040201
Q14:
>> a=(5*pi)/8;
>> b=(pi/8);
>> x=sin(a)*cos(b)
x=
0.853553390593274
>> y=(1/2)*(sin(a-b)+sin(a+b))
y=
0.853553390593274
As x=y (Hence given Identity proved)
Chapter 02:
Q11:
>> i=[1 6 -3 -3 -3 -3 -3 -3 -3]
i=
1 6 -3 -3 -3 -3 -3 -3 -3
>> f=i(3:9)
f=
-3 -3 -3 -3 -3 -3 -3
Here “f” is a row vector contains 7 elements that are all (-3).
Q24 (a):
>> a=[7 2 -3 1 0]
a=
7 2 -3 1 0
b=
-3 10 0 7 -2
>> c=[1 0 4 -6 5]
c=
1 0 4 -6 5
>> u=ones(3)
u=
1 1 1
1 1 1
1 1 1
>> u(1,:)=a(1:3)
u=
7 2 -3
1 1 1
1 1 1
>> u
u=
7 2 -3
1 1 1
1 1 1
>> u(2,:)=b(1:3)
u=
7 2 -3
-3 10 0
1 1 1
>> u(3,:)=c(1:3)
u=
7 2 -3
-3 10 0
1 0 4
Q24 (b):
>> a=[7 2 -3 1 0]
a=
7 2 -3 1 0
b=
-3 10 0 7 -2
>> c=[1 0 4 -6 5]
c=
1 0 4 -6 5
>> v=zeros(3)
v=
0 0 0
0 0 0
0 0 0
>> v
v=
0 0 0
0 0 0
0 0 0
>>
>> v(:,1)=a(3:5)
v=
-3 0 0
1 0 0
0 0 0
>> v(:,2)=b(3:5)
v=
-3 0 0
1 7 0
0 -2 0
>> v(:,3)=c(3:5)
v=
-3 0 4
1 7 -6
0 -2 5
Chapter 03:
Q12(a):
v=
2 4 6 8 10
>> s=[1 1 1 1 1]
s=
1 1 1 1 1
>> a=v.\s
a=
Q12 (b):
>> v=[2 4 6 8 10]
v=
2 4 6 8 10
>> q=[1 1 1 1 1]
q=
1 1 1 1 1
>> b=v.^2.\q
b=
Q12 (c):
v=
2 4 6 8 10
>> c=v./2
c=
1 2 3 4 5
Q12 (d):
>> v=[2 4 6 8 10]
v=
2 4 6 8 10
>> d=v./v
d=
1 1 1 1 1
Q34:
i1
i3 i2
i4
V1 =12V
V2 =24V
R1=20Ω
R2=12Ω
R3=8Ω
R4=6Ω
R5=10Ω
For Loope2
-V2 – (i2- i4)R4 – (i2- i1)R2 =0
-V2 - i2R4 + i4R4 - i2R2 +i1 R2=0
-24-6i2 +6i4 -12i2 +12i1 =0
-24+12i1-18i2+0i3+6i4= 0 (Equ2)
For Loope3
V2 –(i3-–i1)R1–i3R3 =0
V2 - i3R1+ i1R1- i3R3=0
24-20i3+20i1-8i3=0
24+20i1+0i2-28i3+0i4 =0 (Equ3)
For Loope4
- (i4 -i2) R4 - - i4R5 =0
- i4R4 + i2R4 – i4R5 =0
-6i4+6i2-10i4 =0
0+0i1+6i2+0i3-16i4 =0 (Equ4)
Summary of Equations:
12-32i1+12i2+20i3+0i4 =0
-32i1+12i2+20i3+0i4 = -12 (Equ1)
-24+12i1-18i2+0i3+6i4= 0
12i1-18i2+0i3+6i4 = 24 (Equ2)
24+20i1+0i2-28i3+0i4 =0
20i1+0i2-28i3+0i4 = -24 (Equ3)
0+0i1+6i2+0i3-16i4 =0
0i1+6i2+0i3-16i4 =0 (Equ4)
A=
-32 12 20 0
12 -18 0 6
20 0 -28 0
0 6 0 -16
B=
-12
0
-24
0
>> inv(A)
ans =
>> X=inv(A)*B
X=
3.400000000000000
2.590476190476190
3.285714285714286
0.971428571428571
Therefore
i1= 3.4 A
i2= 2.59 A
i3= 3.28 A
i4= 0.97 A
Chapter5:
Q3(a):
>> x=[0:3]
x=
0 1 2 3
>> y=(x+1).*(x-2).*(2.*x-0.25)-exp(x)
y=
>> plot(x,y,'g')
Q3(b):
>> x=[-3:6]
x=
-3 -2 -1 0 1 2 3 4 5 6
>> y=(x+1).*(x-2).*(2.*x-0.25)-exp(x)
y=
Columns 1 through 6
Columns 7 through 10
>> plot(x,y)
Q4:
>> x=[-2:2]
x=
-2 -1 0 1 2
>> y=sqrt(abs(cosd(3.*x)))+sin(x).^2
y=
>> plot(x,y,'r')
Q8(a):
>> t=[-30:-1.6]
t=
Columns 1 through 20
-30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -
12 -11
Columns 21 through 29
-10 -9 -8 -7 -6 -5 -4 -3 -2
>> x=(3.*t)./(1+t.^3)
x=
Columns 1 through 6
Columns 7 through 12
Columns 19 through 24
Columns 25 through 29
>> y=(3.*t.^2)./(1+t.^3)
y=
Columns 1 through 6
Columns 7 through 12
Columns 13 through 18
Columns 19 through 24
Columns 25 through 29
t=
Columns 1 through 6
Columns 7 through 12
Columns 13 through 18
Columns 19 through 24
17.399999999999999 18.399999999999999 19.399999999999999 20.399999999999999
21.399999999999999 22.399999999999999
Columns 25 through 30
Columns 31 through 36
Columns 37 through 41
>> x=(3.*t)./(1+t.^3)
x=
Columns 1 through 6
Columns 7 through 12
Columns 13 through 18
Columns 19 through 24
Columns 25 through 30
Columns 37 through 41
>> y=(3.*t.^2)./(1+t.^3)
y=
Columns 1 through 6
Columns 7 through 12
Columns 13 through 18
Columns 19 through 24
Columns 25 through 30
Columns 31 through 36
Columns 37 through 41
0.084743852425759 0.082415873556673 0.080212370445404 0.078123620287219
0.076140887094601
>> plot(x,t,':b',y,t,'-g')
Chapter4:
Q2:
>> r=4.85/100;
P=100000;
y=10:30;
M=(P*(r/12))./(1-(1+(r/12)).^(-12.*y));
tbl=[y,M];
disp(M)
disp(y)
disp(tbl)
1.0e+03 *
Columns 1 through 6
Columns 13 through 18
Columns 19 through 21
Columns 1 through 20
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
29
Column 21
30
1.0e+03 *
Columns 1 through 6
Columns 7 through 12
Columns 13 through 18
Columns 19 through 24
Columns 25 through 30
0.865457759352513 0.821173725417141 0.783001870280961 0.749794854663779
0.720675227539015 0.694960459103126
Columns 31 through 36
Columns 37 through 42
Note: Here is the link of book from which assignment was completed
https://ecedmans.files.wordpress.com/2014/03/matlab-an-introduction-with-applications-4th-edition.pdf