lambda0 = 9.6;
gamma0 = 0.0016;
Pload = 900;
nj=1;
AvW = 32e6;
t = 12;
%thermal plant%%%
ath = 0.002;
bth = 8;
gamth = 1200;
cth = 0;
Pth0 = (lambda0 - (nj*bth))/((2*nj*ath)-(2*cth*lambda0));
%%%%%hydro plant%%%%%
ah = 6000;
bh = 100000;
ch = 100;
Ph0 = (lambda0 - (nj*ah*gamma0))/(2*lambda0*ch);
Tl = 0.0000045;
%%%%%%%%%%%lambda%%%%%%%%%%%%%%%%%%%%%%
j=1;
for j=1:24
x = Pload - Ph0 - Pth0;
e1 = 0.1;
while x > e1
lambda = lambda0 + 0.25;
Pth = (lambda - (nj*bth))/((2*nj*ath)-(2*cth*lambda));
Ph = (lambda - (nj*ah*gamma0))/(2*lambda*ch);
Ploss = 0.0000045 * Ph^2;
x = Pload + Ploss - Ph - Pth;
if x < e1
lambda = lambda0;
Pth = (lambda - (nj*bth))/((2*nj*ath)-(2*cth*lambda));
Ph = (lambda - (nj*ah*gamma0))/(2*lambda*ch);
Ploss = 0.0000045 * Ph^2;
end
W = bth + ath*Ph;
fprintf('W=%.3f',W);
x = Pload + Ploss - Ph - Pth;
e2 = 50 ;
dW = W - AvW;
end
end
while dW > e2
lambda = (nj *(gamma0*ah)-(2*ath*bth))/((2*cth*Pth)-(2*Tl*Ph));
x = Pload-Ph-Pth;
while x(1)> e1
lambda = lambda + 0.25;
gamma = gamma0 + 0.00001;
Pth = (lambda - (nj*bth))/((2*nj*ath)-(2*cth*lambda));
Ph = (lambda - (nj*ah*gam))/(2*lambda*ch);
Ploss = 0.0000045 * Ph^2;
x = Pload + Ploss - Ph - Pth;
if x(1)< e1
lambda = lambda0;
Pth = (lambda - (nj*bth))/((2*nj*ath)-(2*cth*lambda));
Ph = (lambda - (nj*ah*gamma))/(2*lambda*ch);
Ploss = 0.0000045 * Ph^2;
x = Pload + Ploss - Ph - Pth;
W = bth + ath*Ph;
fprintf('w=%.3f',W);
end
end
tot = W * t ;
if e2 > tot
fprintf('\t%.3f',lambda);
fprintf('\t%.3f',Pth);
fprintf('\t%.3f',Ph);
fprintf('\t%.3f',gamma);
fprintf('\n');
end
end
答案 0 :(得分:1)
你的循环说for j=1:1
。不应该是for j=1:24
?
答案 1 :(得分:0)
你的问题是你的while循环是一个无限循环。第一个while循环中的前5行是常量,因此x
出现为437.5,总是大于e1
,因此循环永远不会终止。此外,我没有看到循环索引在任何地方使用,所以基本上,如果你循环它没有任何区别。
我猜你已经把很多非描述性变量弄糊涂了。我第二次看到卡尔的建议,你试图在命名和命令流程中加入一些命令,然后你会亲自看看如何修复它(提示:我已经告诉你在哪里看了)。