Clear Filters
Clear Filters

Getting the error Index in position 1 exceeds array bounds. Index must not exceed 1. Error in thermotest5 (line 13) h1 = XSteam('h_pT', p1, t1); % Specific Enthalpy at Turbin

3 views (last 30 days)
%XSteam=addpath('C:\Users\ellam\Downloads\XSteam_Matlab_v2.6');
% Load steam property data from the xsteam library
%water = XSteam('water');
% Rankine Cycle Parameters
p1 = 10; % Boiler Pressure [bar]
p2 = 0.05; % Condenser Pressure [bar]
t1 = 500; % Temperature at Turbine Inlet [C]
t3 = 50; % Temperature at Condenser Outlet [C]
mdot = 100; % Mass Flow Rate [kg/s]
% Fluid Properties
h1 = XSteam('h_pT', p1, t1) % Specific Enthalpy at Turbine Inlet
h1 = 3.4790e+03
s1 = XSteam('s_pT', p1, t1) % Specific Entropy at Turbine Inlet
s1 = 7.7640
h2 = XSteam('h_ps', p2, s1) % Specific Enthalpy at Condenser Outlet
h2 = 2.3680e+03
s2 = XSteam('s_pT', p2, t3) % Specific Entropy at Condenser Outlet
s2 = 8.4976
% Stage 1: Turbine
w_turbine = mdot * (h1 - h2); % Turbine Work Output
t2 = XSteam('T_ps', p2, s1)% Temperature at Turbine Outlet
t2 = 32.8755
% Stage 2: Condenser
q_condenser = mdot * (h2 - XSteam('hL_p', p2)) % Heat Removed in Condenser
q_condenser = 2.2302e+05
% Stage 3: Pump
h3s = XSteam('h_ps', p2, s1) % Isentropic Specific Enthalpy at Pump Inlet
h3s = 2.3680e+03
h3 = h2 + (h3s - h2) / 0.85; % Specific Enthalpy at Pump Inlet
w_pump = mdot * (h3 - h2); % Pump Work Input
t4 = XSteam('T_ps', p1, s2) % Temperature at Pump Outlet
t4 = 797.8123
% Stage 4: Boiler
q_boiler = mdot * (h1 - h3); % Heat Added in Boiler
% Efficiency Calculation
q_in = q_boiler;
q_out = q_condenser;
eta = (q_in - q_out) / q_in;
% Display Results
fprintf('Stage 1: Turbine\n');
Stage 1: Turbine
fprintf('Turbine Work Output: %0.2f MW\n', w_turbine / 1e6);
Turbine Work Output: 0.11 MW
fprintf('Turbine Outlet Temperature: %0.2f C\n', t2);
Turbine Outlet Temperature: 32.88 C
fprintf('\n');
fprintf('Stage 2: Condenser\n');
Stage 2: Condenser
fprintf('Heat Removed in Condenser: %0.2f MW\n', q_condenser / 1e6);
Heat Removed in Condenser: 0.22 MW
fprintf('Condenser Outlet Temperature: %0.2f C\n', t3);
Condenser Outlet Temperature: 50.00 C
fprintf('\n');
fprintf('Stage 3: Pump\n');
Stage 3: Pump
fprintf('Pump Work Input: %0.2f MW\n', w_pump / 1e6);
Pump Work Input: 0.00 MW
fprintf('Pump Outlet Temperature: %0.2f C\n', t4);
Pump Outlet Temperature: 797.81 C
fprintf('\n');
fprintf('Stage 4: Boiler\n');
Stage 4: Boiler
fprintf('Heat Added in Boiler: %0.2f MW\n', q_boiler / 1e6);
Heat Added in Boiler: 0.11 MW
fprintf('Boiler Pressure: %0.2f bar\n', p1);
Boiler Pressure: 10.00 bar
fprintf('\n');
fprintf('Rankine Cycle Efficiency: %0.2f %%\n', eta * 100);
Rankine Cycle Efficiency: -100.74 %
  3 Comments
Torsten
Torsten on 13 Mar 2023
Put XSteam.m in your working directory and run the code from above. If you have MATLAB Release 2022b installed, it should work because it works with MATLAB online, as you can see.

Sign in to comment.

Answers (1)

Sai Sumanth Korthiwada
Sai Sumanth Korthiwada on 27 Mar 2023
Hi Ella,
I have executed the code you have mentioned above in MATLAB R2022b, and it worked without any error for me. I have attached the '.mlx' file with the code and an image displaying the execution, for your reference.
Please ensure that the file is present in the working directory path. If not present, in the “Current Folder” browser, right click on the folder in which the file is in and select "Add to path" and click on "select folders and subfolders" option. Now, the file gets added to the MATLAB working directory path. Execute the file again, it should work.
Hope this helps!

Categories

Find more on Introduction to Installation and Licensing 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!