Unable to perform two for loops, with a set value from first for loop into second loop
Show older comments
I am trying to calculate E_tot, E_inEl and E_comp for each p_limit (250, 500 and 750) and output a vector of 8760x3, i have limited experiense with matlab and cant seem to figure this out. Is there anyone that could help me? Excel file can be found in attachment.
I am getting this error when running the script.
Unable to perform assignment because the left and right sides have a different number of elements.
Error in test (line 104)
E_tot(E_tot>E_max)=E_max;
[B]=xlsread('Fullyear(Metnom)');
SI_y=B(:,1);
%parameters
n=0.2; %Efficientcy PV
P_outp=1*10^6; %Wp PV
Area=P_outp/(n*max(SI_y)); %Area [m^2] PV
m_h2=55; %kWh/kg H_2
n_comp=0.1; %Energy for compression 10% of total energy used in eletrolysis
n_coff=0.2; %Dynamic range, cut-off @ 20% (AWE)
p_limit=[250:250:750] %Electrolyzer Size [kWh]
h=1:1:8760; %Hours in year [t]
for i=p_limit
p_lim=p_limit*n_coff; %Electrolyzer production cut-off [kWh] @ (20%)
E_min=p_limit*n_coff+p_lim*n_comp;
E_max=p_limit*(1+n_comp);
for ii=h
E=n*SI_y*Area*10^-3; %Power output PV [kWh]
E_tot=E; %Total power [kWh]
E_tot(E_tot<E_min)=0;
E_tot(E_tot>E_max)=E_max;
E_inEl=E-E*n_comp; %Power input electrolyzer [kWh]
E_inEl(E_inEl<p_lim)=0;
E_inEl(E_inEl>p_limit)=p_limit;
E_comp=E_tot-E_inEl; %Power for compression [kWh]
end
end
Accepted Answer
More Answers (2)
Morten Fosstveit
on 26 Mar 2019
1 Comment
MOHAMED-AMINE BABAY
on 4 Oct 2020
Hii , Could you please send me this program
MOHAMED-AMINE BABAY
on 4 Oct 2020
0 votes
Hii , Could you please send me this program
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!