Matlab Report 2
Matlab Report 2
College of Engineering
Third Year Electrical Power & Machines Department
Economics of Generation & Operation
MATLAB’s Report(2)
1
Table of Contents :
The problem 3
The solution code 5
Sample runtime of code 9
Plotting and figures 11
2
The problem :
3
4
The solution code:
% initialising constants %
k=2; % choosing a value of k or by solving u equation %
c = 5.2; % the value of c will change for each station %
rho=1.2929;
var=[]; % y- axis %
v=[0:25]; % x- axis %
% part a %
for u=0:25
fu = (k/c)*((u/c)^(k-1))*(exp(-(u/c)^k));
var(u+1)=fu;
end
5
% plotting the result %
axis([0 25 0 0.2])
plot(v,var)
% part b %
u_avg1 = c * gamma(1+(1/k)) % first law %
% second law %
res=0;
for u=0:25
fu = (k/c)*((u/c)^(k-1))*(exp(-(u/c)^k));
temp= fu*u;
res = res+temp;
end
6
u_avg2=res
% both laws give the same result %
% part c %
wpd=0;
for u=0:25
fu = (k/c)*((u/c)^(k-1))*(exp(-(u/c)^k));
expr = 0.5*rho*(u^3)*fu;
wpd = res2+expr;
end
wpd
7
% to plot part c %
c_arr = [5.2 3 10.2 19.2 5.4];
wpd_arr = [120.83 23.2 886.06 2300 135.31];
axis([5 20 0 2500]);
stem(c_arr,wpd_arr)
8
Sample runtime of code:
v=
Columns 1 through 10
0 1 2 3 4 5 6 7 8 9
Columns 11 through 20
10 11 12 13 14 15 16 17 18 19
Columns 21 through 26
20 21 22 23 24 25
var =
Columns 1 through 6
0 0.0663 0.1196 0.1511 0.1585 0.1455
Columns 7 through 12
0.1197 0.0894 0.0611 0.0384 0.0222 0.0119
Columns 13 through 18
9
0.0059 0.0027 0.0012 0.0005 0.0002 0.0001
Columns 19 through 24
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
Columns 25 through 26
0.0000 0.0000
u_avg1 =
4.7856
u_avg2 =
4.7856
wpd =
135.3170
10
Plotting and figures :
C = 5.2
11
C=3
12
C = 10.2
13
C = 19.2
14
C = 5.4
15
PWD for the values of C [5.2 3 10.2 19.2 5.4]
16