Sheet Chapter (1) Introduction To MATLAB: Section (A)
Sheet Chapter (1) Introduction To MATLAB: Section (A)
Sheet Chapter (1) Introduction To MATLAB: Section (A)
1
Computer Applications
7) Create M-file to print a table of time and voltages v1 and v2, where time t=0:4π with a step of
0.005, voltage v1=v1max sin(t) and voltage v2= v2max sin(2t). Plot the two voltages with time.
8) Create a vector x from −2 to +2 with an increment of 1. Your vector should be x = [−2, −1, 0, 1,
2]
a. Find the absolute value of each member of the vector.
b. Find the square root of each member of the vector.
c. Find the size of matrix x
9) Find the square root of both −3 and +3.
a. Use the sqrt function.
b. Use the nthroot function. (write your comment)
c. Raise −3 and +3 to the ½ power. (How do the results vary?)
10) Create a vector x from −9 to 12 with an increment of 3.
a. Find the result of x divided by 2.
b. Find the remainder of x divided by 2.
c. Find ex.
d. Find ln(x) (the natural logarithm of x).
e. Find log10 (x) (the common logarithm of x). Explain your results.
f. Use the sign function to determine which of the elements in vector x are positive.
11) Calculate the following:
a. sin(2θ) for θ = 3π.
b. cos(θ ) for 0 ≤ θ ≤ 2π; let π change in steps of 0.2 π.
c. sin−1(1).
d. cos−1(x) for −1 ≤ x ≤1; let x change in steps of 0.2.
e. Find the cosine of 45°.
- Convert the angle from degrees to radians, and then use the cos function.
- Use the cosd function.
f. Find the angle whose sine is 0.5. Is your answer in degrees or radians?
12) Consider the following matrix:
2
Sheet Chapter (1)
a. Sort matrix x.
b. Sort matrix x in descending order.
c. Sort the rows in matrix x.
d. Sort rows in matrix x based on the values in column 3.
15) Consider the following matrix:
a. Use the size function to determine the number of rows and columns in this matrix.
b. Use the sort function to sort each column in ascending order.
3
Computer Applications
4
Sheet Chapter (1)
19) The following table gives the hourly loading of a certain distribution feeder:
hr 1 2 3 4 5 6 7 8 9 10 11 12
Kw 1370 1120 1050 980 980 1075 1230 1450 1509 1520 1640 1750
KVAr 550 530 500 460 500 520 520 650 540 605 700 720
hr 13 14 15 16 17 18 19 20 21 22 23 24
Kw 1720 1740 1680 1530 1630 1760 1850 2020 1980 1720 1660 1580
KVAr 715 685 695 590 635 750 780 800 820 715 650 600
Write script M-file (all in one M-file) to read the measured active and reactive powers then
complete the MATLAB code to do the following;
a. Calculate the feeder loading in VA for each hour and draw the loading curve with respect
to daily hours.
b. Find the maximum loading value and the corresponding hour.
c. Find the average (mean) daily loading.
d. Draw the power factor at the supplying point with time and find the worst and best power
factor and the corresponding hour.
e. Find the circuit breaker ratting current (where the circuit breaker or fuse protection
device is designed to withstand the maximum loading current with a safety factor 125%).
The system voltage is assumed to be constant at 380 volt, 50Hz as a line voltage.
f. At what hour the feeder if heavily loaded.
g. Draw the voltage and current sinewave at hour 7 on the same figure to show the phase
shift between voltage and current as well as other technical information.
h. Draw the needed injected or absorbed reactive power to maintain system power factor at
0.95 lagging.
i. Design a matrix including all system data corresponding to daily hours. The data needed
are system KW, KVAr, I, P.F and S (VA).
j. Sort the previous matrix in ascending order with respect to the feeder current.
k. Find the number of column, rows and the length of the previous matrix.
l. If the supply voltage fluctuates around the nominal value (380V) with a maximum
variation of ±5%. Suppose a random supply voltage within the specified range for each
daily hour. Then design another matrix similar to that in “i”.