Chapter 5
Sheet (5)
x 4 3x 5
1. Write a function file (name it ff501) for the function y x
x 1
2 2
The input to the function is x and the output is 𝑦 𝑥 . Write the function such
that x can be a vector. Use the function to calculate:
(a) 𝑦 𝑥 for 𝑥 3, 𝑥 7
(b) Use the function to make a plot of the function 𝑦 𝑥 for 0 𝑥 10
2. Repeat Question (1) using anonymous function.
3. Write a function file (name it ff503) for the function:
y x 0.6 x3e0.47 x 1.5 x 2e0.6 x
The input to the function is x and the output is 𝑦 𝑥 . Write the function such
that x can be a vector. Use the function to calculate:
(a) 𝑦 𝑥 for 𝑥 2, 𝑥 4
(b) Use the function to make a plot of the function 𝑦 𝑥 for 4 𝑥 8
4. Repeat Question (3) using anonymous function.
5. Write a function file (name it ff505) for the function:
y x e0.17 x x3 2 x 2 0.8 x 3
The input to the function is x and the output is 𝑦 𝑥 . Write the function such
that x can be a vector. Use the function to calculate:
(a) 𝑦 𝑥 for 𝑥 1, 𝑥 3
(b) Use the function to make a plot of the function 𝑦 𝑥 for 0.5 𝑥 4
6. Repeat Question (5) using anonymous function.
1
Introduction to MATLAB
7. The voltage gain of the passive low pass filter circuit in the below figure is
Vo 1
expressed as: Vg where 2 f
Vi 1 RC
2
Write a function file (name it ff507) to calculate the voltage gain for given
values of R, C, and f. Write a script file that uses this function to calculate and
plot the voltage gain for 10 𝑓 100000 𝐻𝑧 and circuit parameters 𝑅
80 Ω and 𝐶 5 𝜇𝐹
8. Repeat Question (7) using anonymous function.
9. The voltage gain of the passive high pass filter circuit in the below figure is
Vo RC
expressed as: Vg where 2 f
Vi 1 RC
2
Write a function file (name it ff509) to calculate the voltage gain for given
values of R, C, and f. Write a script file that uses this function to calculate and
plot the voltage gain for 10 𝑓 100000 𝐻𝑧 and circuit parameters 𝑅
80 Ω and 𝐶 5 𝜇𝐹
10. Repeat Question (9) using anonymous function.
2
Chapter 5
11. The voltage gain of the passive band pass filter circuit in the below figure
Vo L
is expressed as: Vg where 2 f
Vi
L R 1 LC
2
2
Write a function file (name it ff511) to calculate the voltage gain for given
values of R, C, and f. Write a script file that uses this function to calculate and
plot the voltage gain for 10 𝑓 100000 𝐻𝑧 and circuit parameters 𝑅
200 Ω, 𝐿 45 𝑚𝐻 and 𝐶 160 𝜇𝐹
12. Repeat Question (11) using anonymous function.
13. The voltage gain of the passive band reject filter circuit in the below figure
Vo R 1 2 LC
is expressed as: Vg where 2 f
Vi
L R 1 LC
2
2
Write a function file (name it ff513) to calculate the voltage gain for given
values of R, C, and f. Write a script file that uses this function to calculate and
plot the voltage gain for 10 𝑓 100000 𝐻𝑧 and circuit parameters 𝑅
200 Ω, 𝐿 45 𝑚𝐻 and 𝐶 160 𝜇𝐹
3
Introduction to MATLAB
14. Repeat Question (13) using anonymous function.
15. Write a program that accepts a numerical value x from 0 to 100 as input and
computes and displays the corresponding letter grade given by the following
table:
A 𝑥 90
B 80 𝑥 89
C 70 𝑥 79
D 60 𝑥 69
F 𝑥 60
(a) Use if statements in your program (do not use elseif).
(b) Use elseif clauses in your program
16. Repeat Question (15) such that your program allows the user to enter x many
times and stops calculations when a negative value of x is entered.
17. Consider the circuit shown in the below figure. Write a MATLAB program to
calculate the power dissipated in 𝑅 for 2.5 𝑅 30. The program would also plot
the power dissipated versus 𝑅 for the specified range and determine the maximum
power and corresponding value of 𝑅
4
Chapter 5
8 5 Rx 6
15 13
24V + 10 9 11
-
+ 36V + 12V
- -
18. Consider the circuit shown in the below figure. Write a MATLAB program to
calculate the power dissipated in 𝑅 for 0 𝑅 30. The program would also plot the
power dissipated versus 𝑅 for the specified range and determine the maximum power
and corresponding value of 𝑅 . Circuit parameters are: V1 150 0 V ,
V2 100 90 V , 𝑍 5 𝑗7 , 𝑍 6 𝑗13 , 𝑍 10 𝑗12 , 𝑍 𝑅 𝑗7 ,
𝑍 5 𝑗12 , 𝑍 8 𝑗13 , 𝑍 7 𝑗14 ,
19. Use MATLAB to determine the roots of the following equations and plot each one
over the specified period:
(a) x 2 4x 3 0 4 x 0
(b) x 3 5x 2 9x 5 0 3 x 0
(c) 2x 5 4x 4 12x 3 27x 2 8x 16 0 3 x 2
20. Use MATLAB to obtain the partial fraction expansion of the following functions:
7x 2 25x 6 x 3 6x 20
(a) F x (b) F x
3x 3 8x 2 x 2 x 4 2x 3 5x 2 2x 8
x 3 4x 2 2x 2 2x 1
(c) F x (d) F x
x 2 5x 6 x 1 x 1 x 3
5
Introduction to MATLAB
1 2x 1
(e) F x (f) F x
x x 2 x 1
2 2
x 2
2 x 2 1
21. Use MATLAB to express the following functions as quotient of polynomials:
2 1 2 3 1
(a) F x (b) F x
x 3 x 2 x 1 2x 1 x 3
1 2 1
(c) F x x 1
x 1 x 2 x 3
22. Given the following data:
x 1 3 5 6.4 7.2 8 8.4
y 0.2 0.8 2.25 4 6 8.8 11
Use MATLAB to obtain a 5th order polynomial fitting these data. Plot x versus y
along with the corresponding data obtained from the polynomial to evaluate the
accuracy of curve fitting.
23. Given the following data:
x -3 -1.4 0.5 2.4 4 6 7.8 9 10.4 11.5
y -1 1 2 1 -1 -1.4 0 1.8 4 6
Use MATLAB to obtain a 5th order polynomial fitting these data. Plot x versus y
along with the corresponding data obtained from the polynomial to evaluate the
accuracy of curve fitting.
24. The following data represent the open circuit curve of a dc generator obtained from
an experiment:
If 0 0.1 0.165 0.225 0.28 0.37 0.45 0.54 0.65 0.75 0.85
E 8 45 80 110 139 168 198 218 240 253 262
i) Use MATLAB interpolation to obtain the induced emf at the regular spaced
current vector: If = 0.10, 0.15, 0.20, …..
ii) Obtain a 5th order polynomial fitting the given data.
6
Chapter 5
25. The following data represent the torque-speed curve of a dc series motor obtained
from an experiment:
T [Nm] 5.75 5.0 4.2 3.4 2.7 2.1 1.5 1.05 0.7 0.5
N [rpm] 500 800 1300 1800 2250 2750 3500 4500 5000 5750
i) Use MATLAB interpolation to predict the motor speed at torque values of 1 Nm,
2 Nm and 3 Nm
ii) Obtain a 4th order polynomial fitting the given data.
26. Consider the half-wave diode rectifier circuit shown in the below figure.
Use MATLAB to plot the input and output voltage waveforms and calculate
the average and rms values of the output voltage. The input is a sine wave of
amplitude 10V and frequency 50Hz.
D
RL
V
27. Use MATLAB to find the average and rms values of the rectified voltage
obtained from the full-wave diode bridge rectifier shown in the figure if the
input is a sine wave of amplitude 10V and frequency 50Hz.
D11 D21
Vs RL
D12 D22
28. Use MATLAB to find the average and rms values of the output voltage
obtained from the half-wave controlled rectifier shown in the figure if the input
is a sine wave of amplitude 10V and frequency 50Hz. The delay angle is =
30.
7
Introduction to MATLAB
Th
RL
V
29. Use MATLAB to find the average and rms values of the output voltage obtained
from the full-wave half-controlled rectifier shown in the figure if the input is a sine
wave of amplitude 10V and frequency 50Hz. The delay angle is = 45. Find the power
dissipated in a load resistance of RL = 100
Th11 Th21
Vs RL
D12 D22
30. Use MATLAB to find the rms voltage, rms current and power dissipated in RL =
100 for the output of the static voltage regulator shown in the figure. The input is a
sine wave of amplitude 310V and frequency 50Hz. The delay angle is =45.
Th1
Th2 RL
V
31. Use MATLAB to solve the following differential equation:
d 3 y t d 2 y t dy t
3
7 2
14 12 y t 10
dt dt dt
dy 0 d 2 y 0
With the initial conditions: y 0 1 , 2, 5
dt dt 2
Plot y t within the interval 0 t 5 sec
8
Chapter 5
32. Use MATLAB to solve the following differential equation:
d 2 y t dy t
2
5 6 y t 3sin t 7 cos t
dt dt
dy 0
With initial conditions: y 0 4 , 1 .plot y(t) within the interval
dt
0 t 10 s
33. For the following circuit, if the switch is opened at 𝑡 0, find 𝑣 𝑡 . Plot 𝑣 𝑡 for
the time interval 0 𝑡 0.5 𝑆𝑒𝑐
20k 10k
t= 0
30V +
-
40k 1F v o t
34. For the sequential circuit shown in the below figure, initially the current flowing
through the inductor is zero. At 𝑡 0 , the switch moved from position 𝑎 𝑡𝑜 𝑏 ,
where it remained for 1.0 𝑆𝑒𝑐 . After the 1.0 𝑆𝑒𝑐 delay, the switch moved from
𝑏 𝑡𝑜 𝑐 , where it remained indefinitely. Use MATLAB to calculate and plot the
current following through the inductor versus time.
50 a 200H
b
c
40V + 50
- 150
35. For the following RLC circuit, the switch is closed at t = 0. The initial energy in the
storage elements is zero. Use MATLAB to plot vo t
9
Introduction to MATLAB
10 1.25H
t=0 +
8V + 0.25F vo t
-
10