Undefined varialble ? where?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
[EDIT: 20110609 13:08 CDT - reformat - WDR]
hey guys i am trying to find a sum of cashflows based on 4 different scenarios. This is my code and I can only run the program and get a solution from net_income_1. The other 3 net_incomes are returned as undefined. Any ideas?
xin(1) = 500;
xin(2) = 427;
FIT = 12.1;
Xe = 3.1;
RHI = 3;
Pth = 3;
fuel = xin(1)*2.13;
maintenance = xin(1)*0.5;
Pe = 6.5;
Le = xlsread('hourly electric demand.xlsx');
Lth = xlsread('hourly thermal demand.xlsx');
for j=1:1
for i=1:24
if xin(1)>= Le(j,i) && xin(2)>=Lth(j,i);
Feed_in_tariff_1 = Le(j,i)*FIT;
exported_electricity_1 = (Le(j,i)-xin(1))*Xe;
Heat_incentive_1 = Lth(j,i)*RHI;
avoided_electric_1 = Le(j,i)*Pe;
avoided_thermal_1 = Lth(j,i)*Pth;
income_1 = Feed_in_tariff_1+exported_electricity_1+...
avoided_electric_1+avoided_thermal_1+Heat_incentive_1;
expences_1 = fuel+maintenance;
net_income_1 = income_1-expences_1;
elseif xin(1)<=Le(j,i) && xin(2)<=Lth(j,i);
Feed_in_tariff_2 = xin(1)*FIT;
Heat_incentive_2 = (Lth(j,i)-xin(2))*RHI;
avoided_electric_2 = xin(1)*Pe;
avoided_thermal_2 = xin(2)*Pth;
electric_purchase_2 = (Le(j,i)-xin(1))*Pe;
thermal_purchase_2 = (Lth(j,i)-xin(2))*Pth;
income_2 = Feed_in_tariff_2+ Heat_incentive_2 + avoided_electric_2 + avoided_thermal_2;
expences_2 = fuel+maintenance+electric_purchase_2+thermal_purchase_2;
net_income_2 = income_2-expences_2;
elseif xin(1)>=Le(j,i) && xin(2)<=Lth(j,i);
Feed_in_tariff_3 = Le(j,i)*FIT;
Heat_incentive_3 = (Lth(j,i)-xin(2))*RHI;
exported_electric_3 = (Le(j,i)-xin(1))*Xe;
avoided_electric_3 = xin(1)*Pe;
avoided_thermal_3 = xin(2)*Pth;
thermal_purchase_3 = (Le(j,i)-xin(2))*Pth;
income_3=Feed_in_tariff_3 + exported_electric_3 +...
Heat_incentive_3 + avoided_electric_3 + avoided_thermal_3;
expences_3 = fuel+maintenance+thermal_purchase_3;
net_income_3 = income_3 - expences_3;
else
if xin(1)<= Le(j,i) && xin(2)>= Lth(j,i);
Feed_in_tariff_4 = xin(1)*FIT;
Heat_incentive_4 = Lth(j,i)*RHI;
exported_electric_4 = 0;
avoided_electric_4 = Le(j,i)*Pe;
avoided_thermal_4 = xin(2)*Pth;
electric_purchase_4 = (Le(j,i)-xin(1))*Pe;
income_4 = Feed_in_tariff_4 + exported_electric_4 +thermal_purchase_4...
+ Heat_incentive_4 + avoided_electric_4 + avoided_thermal_4 ;
expences_4 = fuel+maintenance+electric_purchase_4;
net_income_4 = income_4 - expences_4;
end
end
end
end
final = net_income_1 + net_income_2
Thanks
2 commentaires
Réponse acceptée
Sean de Wolski
le 9 Juin 2011
I'm not positive, but I'm pretty sure there's a way through your decision tree that doesn't define them. The last outer else forces you into an inner if with no else so when it fails that inner if they're left undefined.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Large Files and Big Data dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!