matlab assignment(complete)
TRANSCRIPT
-
7/24/2019 Matlab Assignment(COMPLETE)
1/16
EMC 201 MEASUREMENT AND INSTRUMENTATION
SEM 1 2015/2016
NAME : MUHAMAD NURHAFIZ BIN RAHIM ( 111551)SCHOOL : MECHANICAL ENGINEERING
LECTURER : DR NORZALILAH MOHAMAD NOR
-
7/24/2019 Matlab Assignment(COMPLETE)
2/16
EXPLANATION OF HOW THE DATA IS EXTRATED
F! "#$%&' *!+,-+. * 2000H
t = 1/fs= 1/2000
= 0.5ms
F! "#$%&' *!+,-+. * 500H
t = 1/fs
= 1/500
= 2ms
F! "#$%&' *!+,-+. * 1000H
t = 1/fs
= 1/1000
= 1ms
F! "#$%&' *!+,-+. * 000H
t = 1/fs
= 1/4000
= 0.25ms
Therefore, the image is overlayed with vertical lines with the interval of 0.5ms, 2ms, 1ms and
0.25ms for the sampling fre!encies of 2000"#, 500"#, 1000"# and 4000"# respectively. Then
the corresponding voltages are ta$en and shown in the ta%les respectively.
-
7/24/2019 Matlab Assignment(COMPLETE)
3/16
(A) S#$%&' F!+,-+. * 2000 H
S#$%&+3 D#4# *! S#$%&' F!+,-+. * 2000 H
M#4 C3+
&'!rpose( i)To o%tain the fre!ency spectr!m!sing fft f!nction in *atla%
& ii)To determine the fre!ency
components and their corresponding amplit!des
Time, t+ms)
oltage,
V(V)
N
T'$+ ($") 7&4#+(7)
14 .5 -.4
15 -
1 -.5
1- 10
1 .5 2
1 -.5
20 .5 4.5
21 10 0.5
22 10.5
2 11 4.
24 11.5 2.525 12
N T'$+ ($") 7&4#+(7)
1 0 5.5
2 0.5 -
1 2
4 1.5 105 2
2.5 -.1
-
.5 2.5
4 2
10 4.5 4.5
11 5 4.5
12 5.5 1.5
1 4
-
7/24/2019 Matlab Assignment(COMPLETE)
4/16
close all &clear all the data
fid = fopen+3*62000"#.t7t3, 3r3) &open the file from the te7t
8 = fscanf+fid, 3&g &g3, 92 inf:) & read the data from the 2 col!mns of the te7t file;=83 & transfer the data from the te7t file
t=;+(,1) & 1 refer to the data at col!mn 1
v=;+(,2) &2 refer to the data at col!mn 2plot+t,v)
7la%el+3Time+ms)3)
yla%el+3
-
7/24/2019 Matlab Assignment(COMPLETE)
5/16
-
7/24/2019 Matlab Assignment(COMPLETE)
6/16
M#4 C3+
&'!rpose( i)To o%tain the fre!ency spectr!m !sing fft f!nction in *atla%& ii)To determine the fre!ency components and their corresponding amplit!des
close all &clear all the datafid = fopen+3*6500"#.t7t3, 3r3) &open the file from the te7t
8 = fscanf+fid, 3&g &g3, 92 inf:) & read the data from the 2 col!mns of the te7t file
;=83 & transfer the data from the te7t filet=;+(,1) & 1 refer to the data at col!mn 1
v=;+(,2) &2 refer to the data at col!mn 2
plot+t,v)
7la%el+3Time+ms)3)yla%el+3
-
7/24/2019 Matlab Assignment(COMPLETE)
7/16
S#$%&+3 D#4# *! S#$%&' F!+,-+. * 1000H
N T'$+ ($") 7&4#+(7)
1 0 5.5
2 1 2
2 5
4
5 4 2
5 4.5
- 4
-
10
10 -.5
11 10 0.5
12 11 4.
1 12
oltage,
V(V)
Time, t+ms)
-
7/24/2019 Matlab Assignment(COMPLETE)
8/16
M#4 C3+
&'!rpose( i)To o%tain the fre!ency spectr!m !sing fft f!nction in *atla%& ii)To determine the fre!ency components and their corresponding amplit!des
close all &clear all the datafid = fopen+3*61000"#.t7t3, 3r3) &open the file from the te7t
8 = fscanf+fid, 3&g &g3, 92 inf:) & read the data from the 2 col!mns of the te7t file;=83 & transfer the data from the te7t file
t=;+(,1) & 1 refer to the data at col!mn 1
v=;+(,2) &2 refer to the data at col!mn 2plot+t,v)
7la%el+3Time+ms)3)
yla%el+3
-
7/24/2019 Matlab Assignment(COMPLETE)
9/16
(D) S#$%&' F!+,-+. * 000H
S#$%&+3 D#4# *! S#$%&' F!+,-+. * 000H
N
T'$+ ($") 7&4#+(7)
oltage,
V(
V)
Time, t+ms)
N T'$+ ($") 7&4#+(7)
1 0.00 5.50
2 0.25 -.00
0.50 -.00
4 0.-5 5.00
5 1.00 1.00
1.25 -.00
- 1.50 10.50
1.-5 10.50
2.00 5.00
10 2.25 2.00
11 2.50 .00
12 2.-5 -.20
1 .00 .00
14 .25 4.50
15 .50 2.50
1 .-5 0.00
1- 4.00 2.00
1 4.25 .50
1 4.50 4.5020 4.-5 5.00
21 5.00 4.50
22 5.25 .50
2 5.50 1.50
24 5.-5 0.50
25 .00 4.00
-
7/24/2019 Matlab Assignment(COMPLETE)
10/16
2 .25 .00
2- .50 -.20
2 .-5 .50
2 -.00 .00
0 -.25 2.00
1 -.50 .00
2 -.-5 10.00
.00 10.00
4 .25 .00
5 .50 4.00
.-5 -.00
- .00 -.20
.25 .50
.50 5.00
40 .-5 .0041 10.00 0.50
42 10.25 1.50
4 10.50 .00
44 10.-5 4.0
45 11.00 4.0
4 11.25 4.00
4- 11.50 2.50
4 11.-5 0.50
4 12.00 2.50
M#4 C3+
&'!rpose( i) To o%tain the fre!ency spectr!m !sing fft f!nction in *atla%& ii) To determine the fre!ency components and their corresponding amplit!des
close all &clear all the datafid = fopen+3*64000"#.t7t3, 3r3) &open the file from the te7t
8 = fscanf+fid, 3&g &g3, 92 inf:) & read the data from the 2 col!mns of the te7t file
;=83 & transfer the data from the te7t filet=;+(,1) & 1 refer to the data at col!mn 1
v=;+(,2) &2 refer to the data at col!mn 2plot+t,v)
7la%el+3Time+ms)3)yla%el+3
-
7/24/2019 Matlab Assignment(COMPLETE)
11/16
amplit!de=a%s+y)A2/@ &calc!late the act!al amplit!de
f=+1(@)/@ &normali#e the scale
fre!ency=fAf6sampling &calc!late the act!al fre!encyfig!re, plot+fre!ency,amplit!de) &plot a graph of act!al amplit!de vers!s act!al fre!ency
7la%el+3?re!ency+"#)3)
yla%el+38mplit!de3)title+3?re!ency >pectr!m for >ampling ?re!ency 4000"#3)
Figure $:Graph "f Voltage(V) Versus Time(s) Figure %: Frequency
Spectrum
EXTRACTED FRE8UENC9 SPECTRA
(A) F! S#$%&' F!+,-+. * 2000 H
(B) F! S#$%&' F!+,-+. * 500 H
F!+,-+.(H) A$%&'4-3+ (7)
-1.4 1.14
142. 2.51
214. 5.14-
F!+,-+.
(H)
A$%&'4-3+(7)
0 0.0
10 0.254
240 0.11
20 0.055--400 .-
40 0.15
50 2.
40 0.1
-20 1.20-
00 0.11-
0 0.25
0 0.451040 0.44
-
7/24/2019 Matlab Assignment(COMPLETE)
12/16
25.- 4.10
(C) F! S#$%&' F!+,-+. * 1000 H
-
7/24/2019 Matlab Assignment(COMPLETE)
13/16
(D) F! S#$%&' F!+,-+. * 000H
N F!+,-+.(H) A$%&'4-3+(7)
1 1. 0.142
2 1.2 0.55
244. 0.4042
4 2.52 0.004
5 40.15 .
4.- 0.42
- 5-1.41 2.4
5.04 0.22-
-4.- 1.04
10 1. 0.1-1
11 -. 0.42
12 -.5 0.1114
1 101.1 0.20
14 1142.2 0.0-
15 1224.45 0.141
1 10.0 0.002
1- 1-.-1 0.15-1 14.4 0.01
1 1550.- 0.0-41
20 12. 0.110
21 1-14.2 0.0-
22 1-5. 0.10-
2 1--.4 0.10
24 15.12 0.101
25 2040.-5 0.052
F!+,-+.(H) A$%&'4-3+(7)
-.2 0.14
15. 0.5
20. 0.-
0-.- 0.554
4. .-
41.5 2.0
5.5 2.2
-
7/24/2019 Matlab Assignment(COMPLETE)
14/16
COMPARISONS BETWEEN ACTUAL AND MEASURED DATA
(A) F! S#$%&' F!+,-+. * 2000H
@o.
?re!ency, f +"#) 'ercentage ofBifference
8mplit!de, +
-
7/24/2019 Matlab Assignment(COMPLETE)
15/16
'ercentage of 'ercentage of
Bifference +&)
8ct!al *eas!red 8ct!al *eas!red
1st 22. 214. .5- .- 5.14- 2.1
2nd 4. 25.- 40. 2. 4.10 41.5
rd 45.2 0.
(C) F! S#$%&' F!+,-+. * 1000 H
@o.
?re!ency, f +"#) 'ercentage ofBifference
8mplit!de, +
-
7/24/2019 Matlab Assignment(COMPLETE)
16/16
fre!encies arenDt. Therefore, the first and second amplit!de o%tained contain small percentage
error of 4.& and 2.0-& whereas the third signal has large percentage error of 14.11&.
Therefore, aliasing occ!rs for the 45.2"# signal fre!ency.
F! "#$%&' *!+,-+. * 000 H, the @y!ist fre!ency is 2000"#. of the signal
fre!encies detected are less than this @y!ist fre!ency. "ence, the percentage error for thefre!ency and the amplit!de o%tained are small which range from 1& to 2-& and 1& to 25&
respectively. Therefore, no aliasing occ!r.
@y!ist fre!ency state that signals with fre!ency lower thanf&yq =fs'2are acc!rately
sampled. >ignals with fre!encies greater than or e!al tof&yq are not acc!rately sampled and
appears as lower fre!encies in the discrete sample.
Ef the fre!ency !sed is lower than the @y!ist rate. Et will e7hi%it aliasing. 8liasing is the
presence of !nwanted components in the reconstr!cted signal and it occ!rs whenever the @y!ist
fre!ency falls %elow the signal fre!ency.
Therefore to get more acc!rate res!lt, it is necessarily to sample at twice the ma7im!m
fre!ency of the signal. The sampling theorem state that a signal can %e e7actly reprod!ces if itis sample at a fre!ency, ? where ? is greater than twice the ma7im!m fre!ency in the signal.
;y comparing fig!re 1, , 5 and - with the trace from the oscilloscope, it is fo!nd that
sampling fre!ency of 2000"# and 4000 "# can plot a !ite similar graph to the original tracefrom the oscilloscope whereas sampling fre!encies of 500"# and 1000 "# acts otherwise. This
is %eca!se aliasing occ!r in %oth 500"# and 1000 "# sampling fre!encies.
CONCLUSION:
?rom the a%ove calc!lation !sing *atla%, it is concl!ded that aliasing will occ!r if the
highest signal fre!ency is greater than the @y!ist fre!ency.
?or this trace from an oscilloscope +