how can i clear the error, Index exceeds the number of array elements. Index must not exceed 10. line (s1(i) = XSteamUS('s_pT',p_inlet(i),t_inlet(i));)
1 view (last 30 days)
Show older comments
Julio Almanzar
on 3 Mar 2023
Commented: Walter Roberson
on 3 Mar 2023
offset_t = 50; % 50degC interval
offset_c = 1; % 1 psi interval
cp_low = 1;
cp_high = 15; % Condenser Pressure Range
nstep_cp = 14;
delta_cp = (cp_high-cp_low)/nstep_cp;
tt_low = 700;
tt_high = 1200; % Turbine Inlet Temperature Range
nstep_tt = 10;
delta_tt = (tt_high-tt_low)/nstep_tt;
tp_low = 2000;
tp_high = 3000; % Turbine Inlet Pressure Range
nstep_tp = 20;
delta_tp = (tp_high-tp_low)/nstep_tp;
nstep_rhp = 16;
rh_ratio_high = 0.9; % Pressure Ratio
rh_ratio_low = 0.1;
delta_rhp = (rh_ratio_high-rh_ratio_low)/nstep_rhp;
for i = 1:nstep_tt % Turbine Temp (700-1200degC)
t_inlet(i) = t1 + (i-1)*delta_tt;
end
for i = 1:nstep_tp
p_inlet(i) = p1 + (i+1) * delta_tp; % Turbine Inlet Pressure
s1(i) = XSteamUS('s_pT',p_inlet(i),t_inlet(i));
s2(i) = s1(i);
rhp = p_inlet * delta_rhp;
t2(i) = XSteamUS('T_ps',p_inlet(i),s2(i));
h2(i) = XSteamUS('h_ps',rhp(i),s2(i));
0 Comments
Accepted Answer
Walter Roberson
on 3 Mar 2023
for i = 1:nstep_tt % Turbine Temp (700-1200degC)
nstep_tt is not defined in the code you posted. We have no reason to expect it is the same as nstep_tp that you do define.
2 Comments
Walter Roberson
on 3 Mar 2023
nstep_tt = 10;
%...
for i = 1:nstep_tt % Turbine Temp (700-1200degC)
t_inlet(i) = t1 + (i-1)*delta_tt;
end
t_inlet is not pre-allocated, so the output size it will have after the loop corresponds to the maximum indexed assigned to, which is max(1:nstep_tt) which is floor(nstep_tt) which is 10. After that loop, up to t_inlet(10) will be assigned to and t_inlet(11) onwards do not exist.
nstep_tp = 20;
%...
for i = 1:nstep_tp
p_inlet(i) = p1 + (i+1) * delta_tp; % Turbine Inlet Pressure
s1(i) = XSteamUS('s_pT',p_inlet(i),t_inlet(i));
nstep_tp is 20. When i reaches 11 in this loop, the assignment to s1(i) would effectively be
s1(11) = XSteamUS('s_pT',p_inlet(11),t_inlet(11));
but only up to t_inlet(10) was created.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!